1. Download our Official Android App: Forums for Android!

Apps Sizing Issues between Emulator and Devices

Discussion in 'Android Development' started by TDSCruizer, Sep 3, 2016.

  1. TDSCruizer

    TDSCruizer Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Sep 3, 2016

    Sep 3, 2016
    2
    0
    5
    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:eek:nClick="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.
     

    Advertisement

  2. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,324
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,324
    10,452
    1,988
    Male
    Software developer
    South West of England
    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?
     
  3. TDSCruizer

    TDSCruizer Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Sep 3, 2016

    Sep 3, 2016
    2
    0
    5
    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.
     

Share This Page

Loading...