• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Sizing Issues between Emulator and Devices

So I have a Parrot Asteroid Smart android device which unsurprisingly doesn't exist in Android Studio Emulator devices. So I made my own based on the published screen resolution stats of 800 x 480. I have created a car launcher app which works perfectly in the emulator. However, when installing it to the Parrot Asteroid Smart the background image appears the correct size but the image buttons I have used are in the wrong place and are reasonably oversized (about twice the size).

It looked to me as though the device was running in a resolution more like 480 x 320. So I followed some guides and ran some commands to display the system resolution and density these were

adb shell getprop | find "density"
adb shell dumpsys window | find "DisplayWidth"
adb shell dumpsys window | find "DisplayHeight"

They confirmed the Device is running at a density of 240 and a resolution of 736x480(which accounts for standard button bar on the right). I also used ddms to take a screenshot on the device which also came out at 800x480.

I guess I am looking to someone with more experience of android devices and troubleshooting to explain if I am doing something wrong. I have tried all sort of things to my app code and the image buttons to maintain their size and position to the point I am now convinced it is the device displaying them incorrectly. This is my first ever android app so maybe my understanding of the basics of resolution and pixel density is at fault but it seems odd that it all looks find on the emulator but not on the device itself.

FYI Below is the code for the image button I am using, note that the screenshot of the device show this buttons size and position to be greater than what is listed below in margin and layout.

<ImageButton
android:layout_width="340dp"
android:layout_height="74dp"
android:id="@+id/radioButton"
android:src="@drawable/radio_click"
android:background="@Null"
android:padding="0dp"
android:onClick="OpenRadio"
android:scaleType="fitCenter"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="9dp"
android:layout_marginTop="79dp" />

Any help is greatly appreciated.
 
I normally use a RelativeLayout or LinearLayout to contain components like buttons, and set the width and height of the button to "wrap_content". Have you tried that?
 
Thanks for the reply. I am using a Linear layout at present. However, about another hour after the original post as a last resort I created a drawable-hdpi folder and moved all the buttons images in there. This seemed to resolve the issue.
 
Back
Top Bottom