# Android width and height issue

**URL:** <https://discourse.processing.org/t/android-width-and-height-issue/14511>\
**Category:** Processing for Android\
**Created:** [October 8, 2019, 11:26am UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511 "2019-10-08T11:26:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yash](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@Yash](https://discourse.processing.org/u/Yash)\
**Post date:** [October 8, 2019, 11:26am UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511/1 "2019-10-08T11:26:06Z")

</div>

Hi…i am displaying text at width/2-100 , height/2 -100 ,the ellipse is at (width/2 , height/2 ,200,200)…The text is expected to start at the beginning of the ellipse…but it varies according to the phone…in some phones it goes way right  
CONCLUSION: The co ordinates vary from phone to phone.how to solves this.

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [October 8, 2019, 5:15pm UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511/2 "2019-10-08T17:15:19Z")

</div>

@Yash === can you precise the phones you are using (what phone display right and what phone display false) because i cannot see any reason for that (from your code). Also some screenshots will be usefull…

---

<div class="post-metadata">

**Author:** ![Yash](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@Yash](https://discourse.processing.org/u/Yash)\
**Post date:** [October 8, 2019, 5:46pm UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511/3 "2019-10-08T17:46:43Z")

</div>

![sketchu](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/acd8899330fbf603bfcf2c1ed6db200a1215cb51.png) ![IMG-20191008-WA0006](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/aa705f16f7801fdbb0c1ded9ffe45ecd25426bfd.jpeg)

First one is redmi note5 pro  
Second is y2  
Using fullscreen() in setup.

I meant right side’(right)  
Also the ellipse scale differs from phone to phone.I saw displaydensity variable in forum… what exactly is it…does it affect my rest of code where i use the radius of ellipse.  
The size of shapes and text vary from phone to phone as you see in the image

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [October 9, 2019, 11:26am UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511/4 "2019-10-09T11:26:19Z")

</div>

@Yash === the 2 phones are very different from res dpi point of view; first one is xxhdpi or xxxhdpi, second one is mdpi or hdpi; that explains why the size of the shapes changes: it has to be smaller for the 1°, bigger for the second one (and you can easily calculate the ratio for the change); that also explains why the textSize changes according to the same ratio. Normally android solves this kind of problem using as units not the pixels but what it calls dip (density independent pixel) that you can calculate (and code, i can put code for that)… Now, what i cannot understand is that the textstyle is not the same (ital and standard) and also why the “score 0” is at the same coord in the 2 cases and not the other text; could you put the complete code you are using at this moment, complete= from the setup to the ellipse and text.

---

<div class="post-metadata">

**Author:** ![Yash](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@Yash](https://discourse.processing.org/u/Yash)\
**Post date:** [October 9, 2019, 12:19pm UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511/5 "2019-10-09T12:19:45Z")

</div>

Sorry for not mentioning.i have changed the font style for my phone just to test the fonts…and also initially i have set the text using cordiantes like 900,600 which made the text to the center in my phone not the others…  
I have recently put width/2 -100 height/2 -100 but haven’t debugged in other phones.does that work on other phones the same?Thanks for responding.You are so kind

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [October 9, 2019, 1:33pm UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511/6 "2019-10-09T13:33:23Z")

</div>

@Yash === as for testing on other phones you have to put the code you are using… Another difference could explain the problem: first one is (default) orientation landscape, other one is portrait.

---

<div class="post-metadata">

**Author:** ![Yash](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@Yash](https://discourse.processing.org/u/Yash)\
**Post date:** [October 10, 2019, 3:22am UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511/7 "2019-10-10T03:22:30Z")

</div>

No both are landscape…so i wll try out the code in other phones after you suggest me how to implement dpi… should i multiply the size of text and shapes with displaydensity…does that affect my collisions …?

---

<div class="post-metadata">

**Author:** ![Yash](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@Yash](https://discourse.processing.org/u/Yash)\
**Post date:** [October 10, 2019, 4:10am UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511/8 "2019-10-10T04:10:38Z")

</div>

After implementing dpi…and scaling everything to the original irrespective of device … i wl try it out in other phones and see it works… so please tell about dpi implementation

---

<div class="post-metadata">

**Author:** ![Yash](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@Yash](https://discourse.processing.org/u/Yash)\
**Post date:** [October 10, 2019, 4:14am UTC](https://discourse.processing.org/t/android-width-and-height-issue/14511/9 "2019-10-10T04:14:34Z")

</div>

Regarding width and height… i used fullscreen ()…and then width and height…do i need to get device specific width and height.how could i do that in processing for android?

Its not about the orientation or something ,the code is same for both, i ve just shared the app in other phone.  
Help me fix the above two issues i think that will work 😊
