1

I have a button coded as below

        <Button
            android:id="@+id/btn_register"
            style="@style/MyButtonStyle"
            android:layout_width="20dp"
            android:layout_height="10dp"
            android:text="@string/word_text" />

My style is as below.

<style name="MyButtonStyle" >
    <item name="android:textColor">@color/colorWhite</item>
    <item name="android:textAllCaps">false</item>
    <item name="android:textSize">@dimen/text_size_medium_small</item>
    <item name="android:stateListAnimator">@null</item>
    <item name="android:elevation">@dimen/elevation_standard</item>
    <item name="android:backgroundTint">@color/colorPrimary</item>
</style>

If I view on Nexus 5 Android M, the button disappear without any height. If I view on Samsung S7 Android M, it shows the 10dp height.

If I have something bigger than 10dp height or wrap_content, the Samsung S7 shows a thicker button than Nexus 5. Any reason why is this happening? How could I make the height consistent?

Elye
  • 53,639
  • 54
  • 212
  • 474

2 Answers2

0

Emulators and hardware devices can give diffrent results sometimes. If you're testing it with an emulator, give a hardwarde device a try. Screen sizes also matter.

http://developer.android.com/guide/practices/screens_support.html

The android developer forum has a good article about diffrent screen sizes and supporting each.

0

I'm having the same issue. The UI elements of my app look huge on a Samsung S7, but across all other devices the views are a consistent physical size (which is what I expect - isn't that the whole point of density independent pixels?).

I think it has something to do with the Quad HD resolution of the Samsung S7 causing everything to look larger than they would normally. If you go into the device settings, you can set the display to condensed mode and the views will be the same size as on other devices. I'm not sure of a way to handle this issue programmatically though...

starkej2
  • 11,391
  • 6
  • 35
  • 41