How to determine android device resolution is small, medium, or largeHow to save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?Is there a unique Android device ID?Android - Screen Resolution and Screen DensityLayout issues related to Multiple Screens SupportAndroid screen resolutionAndroid Tablets resolution and density supportHow to fake screen resolutionScreen size and dpi of bitmapsHow to get screen width dpi in ANDROID?

Sending a photo of my bank account card to the future employer

Re-negotiate salary once I earn my diploma

Why is "dark" an adverb in this sentence?

I gave my characters names that are exactly like another book. Is it a problem?

How to change checkbox react correctly?

Why should I cook the flour first when making bechamel sauce?

Why do candidates not quit if they no longer have a realistic chance to win in the 2020 US presidents election

Video editor for YouTube

Do aircraft cabins have suspension?

Why don't commercial aircraft adopt a slightly more seaplane-like design to allow safer ditching in case of emergency?

How to honestly answer questions from a girlfriend like "How did you find this place" without giving the impression I'm always talking about my exes?

How to unload a Mathematica package?

Why did Steve Rogers choose Sam in Endgame?

What made Windows ME so crash-prone?

Was all the fuel expended in each stage of a Saturn V launch?

Are L-functions uniquely determined by their values at negative integers?

Getting fresh water in the middle of hypersaline lake in the Bronze Age

Is there a good program to play chess online in ubuntu?

Can't update Ubuntu 18.04.2

What do mathematicians mean when they say some conjecture can’t be proven using the current technology?

Is this artwork (used in a video game) real?

Did the First Order follow Poe to Jakku, or did they independently discover that the map fragment was there?

Doing research in academia and not liking competition

What's the meaning of こそ in this sentence?



How to determine android device resolution is small, medium, or large


How to save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?Is there a unique Android device ID?Android - Screen Resolution and Screen DensityLayout issues related to Multiple Screens SupportAndroid screen resolutionAndroid Tablets resolution and density supportHow to fake screen resolutionScreen size and dpi of bitmapsHow to get screen width dpi in ANDROID?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am working on a Xamarin.Forms app and I need to identify the android screen/resolution is whether small, medium or large to adjust some content with the available space. For example, some labels (single line) are getting truncated in smaller devices. So I could make some adjustments if the resolution is smaller or not.



In iOS, when iPhone screen getting bigger, the resolution is also getting increased so it's easy to identify smaller resolution devices in iOS. But in android, this seems hard.



Android device resolution can be taken from



var resolutionH = Resources.DisplayMetrics.HeightPixels;
var resolutionW = Resources.DisplayMetrics.WidthPixels;


For testing, I have created the following emulators and run the app in them. Here's my result whether a label getting truncated or not.



Resolution Density Result
---------------------------
2560x1440 560 OK
1920x1080 400 OK

1280x720 320 Truncated
1280x720 280 OK
1280x720 240 OK
800x480 240 Truncated
800x480 160 OK


The problem here is a device with higher resolution and lower DPI won't cause any problem. Like a device with 1280x720 resolution and 240 DPI (or 280 DPI). Since there are tons of Android devices are available with different resolutions and densities this problem seems harder.



Is there a better way to categorized android devices (small, medium, and large)?










share|improve this question






























    0















    I am working on a Xamarin.Forms app and I need to identify the android screen/resolution is whether small, medium or large to adjust some content with the available space. For example, some labels (single line) are getting truncated in smaller devices. So I could make some adjustments if the resolution is smaller or not.



    In iOS, when iPhone screen getting bigger, the resolution is also getting increased so it's easy to identify smaller resolution devices in iOS. But in android, this seems hard.



    Android device resolution can be taken from



    var resolutionH = Resources.DisplayMetrics.HeightPixels;
    var resolutionW = Resources.DisplayMetrics.WidthPixels;


    For testing, I have created the following emulators and run the app in them. Here's my result whether a label getting truncated or not.



    Resolution Density Result
    ---------------------------
    2560x1440 560 OK
    1920x1080 400 OK

    1280x720 320 Truncated
    1280x720 280 OK
    1280x720 240 OK
    800x480 240 Truncated
    800x480 160 OK


    The problem here is a device with higher resolution and lower DPI won't cause any problem. Like a device with 1280x720 resolution and 240 DPI (or 280 DPI). Since there are tons of Android devices are available with different resolutions and densities this problem seems harder.



    Is there a better way to categorized android devices (small, medium, and large)?










    share|improve this question


























      0












      0








      0


      1






      I am working on a Xamarin.Forms app and I need to identify the android screen/resolution is whether small, medium or large to adjust some content with the available space. For example, some labels (single line) are getting truncated in smaller devices. So I could make some adjustments if the resolution is smaller or not.



      In iOS, when iPhone screen getting bigger, the resolution is also getting increased so it's easy to identify smaller resolution devices in iOS. But in android, this seems hard.



      Android device resolution can be taken from



      var resolutionH = Resources.DisplayMetrics.HeightPixels;
      var resolutionW = Resources.DisplayMetrics.WidthPixels;


      For testing, I have created the following emulators and run the app in them. Here's my result whether a label getting truncated or not.



      Resolution Density Result
      ---------------------------
      2560x1440 560 OK
      1920x1080 400 OK

      1280x720 320 Truncated
      1280x720 280 OK
      1280x720 240 OK
      800x480 240 Truncated
      800x480 160 OK


      The problem here is a device with higher resolution and lower DPI won't cause any problem. Like a device with 1280x720 resolution and 240 DPI (or 280 DPI). Since there are tons of Android devices are available with different resolutions and densities this problem seems harder.



      Is there a better way to categorized android devices (small, medium, and large)?










      share|improve this question
















      I am working on a Xamarin.Forms app and I need to identify the android screen/resolution is whether small, medium or large to adjust some content with the available space. For example, some labels (single line) are getting truncated in smaller devices. So I could make some adjustments if the resolution is smaller or not.



      In iOS, when iPhone screen getting bigger, the resolution is also getting increased so it's easy to identify smaller resolution devices in iOS. But in android, this seems hard.



      Android device resolution can be taken from



      var resolutionH = Resources.DisplayMetrics.HeightPixels;
      var resolutionW = Resources.DisplayMetrics.WidthPixels;


      For testing, I have created the following emulators and run the app in them. Here's my result whether a label getting truncated or not.



      Resolution Density Result
      ---------------------------
      2560x1440 560 OK
      1920x1080 400 OK

      1280x720 320 Truncated
      1280x720 280 OK
      1280x720 240 OK
      800x480 240 Truncated
      800x480 160 OK


      The problem here is a device with higher resolution and lower DPI won't cause any problem. Like a device with 1280x720 resolution and 240 DPI (or 280 DPI). Since there are tons of Android devices are available with different resolutions and densities this problem seems harder.



      Is there a better way to categorized android devices (small, medium, and large)?







      android xamarin.forms xamarin.android






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 8:55







      Tharindu

















      asked Mar 26 at 7:25









      TharinduTharindu

      517 bronze badges




      517 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          0














          What you are looking for is easy to do in native android you can create a method and check for the DensityMetricsDensity something like below:



          private string GetDeviceDensity()

          var density = Resources.DisplayMetrics.DensityDpi;
          switch (density)

          case DisplayMetricsDensity.Medium:
          return "MDPI";
          case DisplayMetricsDensity.High:
          return "HDPI";
          case DisplayMetricsDensity.Low:
          return "LDPI";
          case DisplayMetricsDensity.Xhigh:
          return "XHDPI";
          case DisplayMetricsDensity.Tv:
          return "TV";
          case DisplayMetricsDensity.Xxhigh:
          return "XXHDPI";
          case DisplayMetricsDensity.Xxxhigh:
          return "XXXHDPI";
          default:
          return "Unknown";







          share|improve this answer























          • You see, in the tested emulator list, 240dpi and 280dpi devices would fall into HDPI bucket. A device with resolution 1280x720 won't cause a problem since it has higher resolution, but 800x480 resolution will.

            – Tharindu
            Mar 26 at 8:24











          • 800 x 400 is this device in landscape or potrait?

            – G.hakim
            Mar 26 at 8:40











          • all the mentioned devices are portrait.

            – Tharindu
            Mar 26 at 8:56











          • Why not just check the display metrics and if it is 800x400 do something different according to the case

            – G.hakim
            Mar 26 at 9:27











          • Actually, I am looking for a more general solution.

            – Tharindu
            Mar 26 at 9:41


















          0














          The reason where a label's text getting truncated (in my case) or an element doesn't get enough space in a particular device is, the actual pixel calculation for an element using the density (dpi/ppi) and the density bucket that screen falls into. This article gives a good idea about calculating the physical size of an element for different display densities.



          After some exhausting research, I was able to categorize the device screen by taking the combination of screen width pixels and density. (I got the data from Android developer website Distribution dashboard and Support different screen sizes)



          I have categorized the screen width pixels into 4 categories and then calculated the screen size for each display density using following formula:



          sqrt((widthPixels x widthPixels) + (heightPixels x heightPixels)) / density


          screen configurations



          Then I have searched in the GSMArena to find devices with the screen configurations in the above table. Screen size lower than 3 inches is mostly smartwatches and more than 8 inches could be Tabs and smart TVs. So I have taken devices with the screen size between 3 - 8 inches as mobile devices.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55351752%2fhow-to-determine-android-device-resolution-is-small-medium-or-large%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            What you are looking for is easy to do in native android you can create a method and check for the DensityMetricsDensity something like below:



            private string GetDeviceDensity()

            var density = Resources.DisplayMetrics.DensityDpi;
            switch (density)

            case DisplayMetricsDensity.Medium:
            return "MDPI";
            case DisplayMetricsDensity.High:
            return "HDPI";
            case DisplayMetricsDensity.Low:
            return "LDPI";
            case DisplayMetricsDensity.Xhigh:
            return "XHDPI";
            case DisplayMetricsDensity.Tv:
            return "TV";
            case DisplayMetricsDensity.Xxhigh:
            return "XXHDPI";
            case DisplayMetricsDensity.Xxxhigh:
            return "XXXHDPI";
            default:
            return "Unknown";







            share|improve this answer























            • You see, in the tested emulator list, 240dpi and 280dpi devices would fall into HDPI bucket. A device with resolution 1280x720 won't cause a problem since it has higher resolution, but 800x480 resolution will.

              – Tharindu
              Mar 26 at 8:24











            • 800 x 400 is this device in landscape or potrait?

              – G.hakim
              Mar 26 at 8:40











            • all the mentioned devices are portrait.

              – Tharindu
              Mar 26 at 8:56











            • Why not just check the display metrics and if it is 800x400 do something different according to the case

              – G.hakim
              Mar 26 at 9:27











            • Actually, I am looking for a more general solution.

              – Tharindu
              Mar 26 at 9:41















            0














            What you are looking for is easy to do in native android you can create a method and check for the DensityMetricsDensity something like below:



            private string GetDeviceDensity()

            var density = Resources.DisplayMetrics.DensityDpi;
            switch (density)

            case DisplayMetricsDensity.Medium:
            return "MDPI";
            case DisplayMetricsDensity.High:
            return "HDPI";
            case DisplayMetricsDensity.Low:
            return "LDPI";
            case DisplayMetricsDensity.Xhigh:
            return "XHDPI";
            case DisplayMetricsDensity.Tv:
            return "TV";
            case DisplayMetricsDensity.Xxhigh:
            return "XXHDPI";
            case DisplayMetricsDensity.Xxxhigh:
            return "XXXHDPI";
            default:
            return "Unknown";







            share|improve this answer























            • You see, in the tested emulator list, 240dpi and 280dpi devices would fall into HDPI bucket. A device with resolution 1280x720 won't cause a problem since it has higher resolution, but 800x480 resolution will.

              – Tharindu
              Mar 26 at 8:24











            • 800 x 400 is this device in landscape or potrait?

              – G.hakim
              Mar 26 at 8:40











            • all the mentioned devices are portrait.

              – Tharindu
              Mar 26 at 8:56











            • Why not just check the display metrics and if it is 800x400 do something different according to the case

              – G.hakim
              Mar 26 at 9:27











            • Actually, I am looking for a more general solution.

              – Tharindu
              Mar 26 at 9:41













            0












            0








            0







            What you are looking for is easy to do in native android you can create a method and check for the DensityMetricsDensity something like below:



            private string GetDeviceDensity()

            var density = Resources.DisplayMetrics.DensityDpi;
            switch (density)

            case DisplayMetricsDensity.Medium:
            return "MDPI";
            case DisplayMetricsDensity.High:
            return "HDPI";
            case DisplayMetricsDensity.Low:
            return "LDPI";
            case DisplayMetricsDensity.Xhigh:
            return "XHDPI";
            case DisplayMetricsDensity.Tv:
            return "TV";
            case DisplayMetricsDensity.Xxhigh:
            return "XXHDPI";
            case DisplayMetricsDensity.Xxxhigh:
            return "XXXHDPI";
            default:
            return "Unknown";







            share|improve this answer













            What you are looking for is easy to do in native android you can create a method and check for the DensityMetricsDensity something like below:



            private string GetDeviceDensity()

            var density = Resources.DisplayMetrics.DensityDpi;
            switch (density)

            case DisplayMetricsDensity.Medium:
            return "MDPI";
            case DisplayMetricsDensity.High:
            return "HDPI";
            case DisplayMetricsDensity.Low:
            return "LDPI";
            case DisplayMetricsDensity.Xhigh:
            return "XHDPI";
            case DisplayMetricsDensity.Tv:
            return "TV";
            case DisplayMetricsDensity.Xxhigh:
            return "XXHDPI";
            case DisplayMetricsDensity.Xxxhigh:
            return "XXXHDPI";
            default:
            return "Unknown";








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 26 at 7:32









            G.hakimG.hakim

            6,1352 gold badges11 silver badges37 bronze badges




            6,1352 gold badges11 silver badges37 bronze badges












            • You see, in the tested emulator list, 240dpi and 280dpi devices would fall into HDPI bucket. A device with resolution 1280x720 won't cause a problem since it has higher resolution, but 800x480 resolution will.

              – Tharindu
              Mar 26 at 8:24











            • 800 x 400 is this device in landscape or potrait?

              – G.hakim
              Mar 26 at 8:40











            • all the mentioned devices are portrait.

              – Tharindu
              Mar 26 at 8:56











            • Why not just check the display metrics and if it is 800x400 do something different according to the case

              – G.hakim
              Mar 26 at 9:27











            • Actually, I am looking for a more general solution.

              – Tharindu
              Mar 26 at 9:41

















            • You see, in the tested emulator list, 240dpi and 280dpi devices would fall into HDPI bucket. A device with resolution 1280x720 won't cause a problem since it has higher resolution, but 800x480 resolution will.

              – Tharindu
              Mar 26 at 8:24











            • 800 x 400 is this device in landscape or potrait?

              – G.hakim
              Mar 26 at 8:40











            • all the mentioned devices are portrait.

              – Tharindu
              Mar 26 at 8:56











            • Why not just check the display metrics and if it is 800x400 do something different according to the case

              – G.hakim
              Mar 26 at 9:27











            • Actually, I am looking for a more general solution.

              – Tharindu
              Mar 26 at 9:41
















            You see, in the tested emulator list, 240dpi and 280dpi devices would fall into HDPI bucket. A device with resolution 1280x720 won't cause a problem since it has higher resolution, but 800x480 resolution will.

            – Tharindu
            Mar 26 at 8:24





            You see, in the tested emulator list, 240dpi and 280dpi devices would fall into HDPI bucket. A device with resolution 1280x720 won't cause a problem since it has higher resolution, but 800x480 resolution will.

            – Tharindu
            Mar 26 at 8:24













            800 x 400 is this device in landscape or potrait?

            – G.hakim
            Mar 26 at 8:40





            800 x 400 is this device in landscape or potrait?

            – G.hakim
            Mar 26 at 8:40













            all the mentioned devices are portrait.

            – Tharindu
            Mar 26 at 8:56





            all the mentioned devices are portrait.

            – Tharindu
            Mar 26 at 8:56













            Why not just check the display metrics and if it is 800x400 do something different according to the case

            – G.hakim
            Mar 26 at 9:27





            Why not just check the display metrics and if it is 800x400 do something different according to the case

            – G.hakim
            Mar 26 at 9:27













            Actually, I am looking for a more general solution.

            – Tharindu
            Mar 26 at 9:41





            Actually, I am looking for a more general solution.

            – Tharindu
            Mar 26 at 9:41













            0














            The reason where a label's text getting truncated (in my case) or an element doesn't get enough space in a particular device is, the actual pixel calculation for an element using the density (dpi/ppi) and the density bucket that screen falls into. This article gives a good idea about calculating the physical size of an element for different display densities.



            After some exhausting research, I was able to categorize the device screen by taking the combination of screen width pixels and density. (I got the data from Android developer website Distribution dashboard and Support different screen sizes)



            I have categorized the screen width pixels into 4 categories and then calculated the screen size for each display density using following formula:



            sqrt((widthPixels x widthPixels) + (heightPixels x heightPixels)) / density


            screen configurations



            Then I have searched in the GSMArena to find devices with the screen configurations in the above table. Screen size lower than 3 inches is mostly smartwatches and more than 8 inches could be Tabs and smart TVs. So I have taken devices with the screen size between 3 - 8 inches as mobile devices.






            share|improve this answer



























              0














              The reason where a label's text getting truncated (in my case) or an element doesn't get enough space in a particular device is, the actual pixel calculation for an element using the density (dpi/ppi) and the density bucket that screen falls into. This article gives a good idea about calculating the physical size of an element for different display densities.



              After some exhausting research, I was able to categorize the device screen by taking the combination of screen width pixels and density. (I got the data from Android developer website Distribution dashboard and Support different screen sizes)



              I have categorized the screen width pixels into 4 categories and then calculated the screen size for each display density using following formula:



              sqrt((widthPixels x widthPixels) + (heightPixels x heightPixels)) / density


              screen configurations



              Then I have searched in the GSMArena to find devices with the screen configurations in the above table. Screen size lower than 3 inches is mostly smartwatches and more than 8 inches could be Tabs and smart TVs. So I have taken devices with the screen size between 3 - 8 inches as mobile devices.






              share|improve this answer

























                0












                0








                0







                The reason where a label's text getting truncated (in my case) or an element doesn't get enough space in a particular device is, the actual pixel calculation for an element using the density (dpi/ppi) and the density bucket that screen falls into. This article gives a good idea about calculating the physical size of an element for different display densities.



                After some exhausting research, I was able to categorize the device screen by taking the combination of screen width pixels and density. (I got the data from Android developer website Distribution dashboard and Support different screen sizes)



                I have categorized the screen width pixels into 4 categories and then calculated the screen size for each display density using following formula:



                sqrt((widthPixels x widthPixels) + (heightPixels x heightPixels)) / density


                screen configurations



                Then I have searched in the GSMArena to find devices with the screen configurations in the above table. Screen size lower than 3 inches is mostly smartwatches and more than 8 inches could be Tabs and smart TVs. So I have taken devices with the screen size between 3 - 8 inches as mobile devices.






                share|improve this answer













                The reason where a label's text getting truncated (in my case) or an element doesn't get enough space in a particular device is, the actual pixel calculation for an element using the density (dpi/ppi) and the density bucket that screen falls into. This article gives a good idea about calculating the physical size of an element for different display densities.



                After some exhausting research, I was able to categorize the device screen by taking the combination of screen width pixels and density. (I got the data from Android developer website Distribution dashboard and Support different screen sizes)



                I have categorized the screen width pixels into 4 categories and then calculated the screen size for each display density using following formula:



                sqrt((widthPixels x widthPixels) + (heightPixels x heightPixels)) / density


                screen configurations



                Then I have searched in the GSMArena to find devices with the screen configurations in the above table. Screen size lower than 3 inches is mostly smartwatches and more than 8 inches could be Tabs and smart TVs. So I have taken devices with the screen size between 3 - 8 inches as mobile devices.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 1 at 6:23









                TharinduTharindu

                517 bronze badges




                517 bronze badges



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55351752%2fhow-to-determine-android-device-resolution-is-small-medium-or-large%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현