layout - Android different button size on real device vs emulator -


my android app looks different on real device (samsung galaxy mini http://www.gsmarena.com/samsung_galaxy_mini_s5570-3725.php ) on emulator.

i have latest sdk, avd set 240x320 ldpi (120ppi)

my layout: have vertical linerlayout 4 items: 4x horizontal linerlayout

    <linearlayout             android:id="@+id/linearlayoutmainlines"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:orientation="vertical" >              <linearlayout                 android:id="@+id/linearlayoutmainline1"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:gravity="center_horizontal"                 android:orientation="horizontal" >             </linearlayout>              ....              <linearlayout                 android:id="@+id/linearlayoutmainline4"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:gravity="center_horizontal"                 android:orientation="horizontal" >             </linearlayout>         </linearlayout> 

then code, add 10 buttons 4 'linearlayoutmainline' @ end have 4x10 buttons on screen.

 button button = new button(_context);  button.settypeface( typeface.monospace, typeface.bold);  button.setonclicklistener(this);  button.settextcolor(0xffffffff);  button.settext(letter);      button.setbackgroundresource(id); ....later....  forall (buttons_line1)     layout1.addview(button); ....  forall (buttons_line4)     layout4.addview(button); 

note that, background image , text of buttons changed code time-to-time, not remain same created with. however, used images same sized (double-checked), , buttons' text 1 letter.

the problem:

on emulator: have 4x10 buttons size 19x36

on mini device: have 3x10 buttons size 19x38, , 4th row 19x32. last row of buttons shorter texts cut in half.

the used images: res\ldpi\button.9.png 18x26 sized.

what cause difference?

i attaching merged screenshot, left device, right emulator.

enter image description here

by spec, mini has ~127 ppi, maybe problem? cannot set emulator, has fixed list density, , 120 closest. however, there it's fine mentioned.

any tips appreciated. thanks


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -