2

I have carema.png and carema_sel.png images in drawable-hdpi and a carema_btn.xml layout file. On Android 2.2 and 2.3 devices, things appear normal, but in android 4.0, the button is too big. Here is my layout:

<?xml version="1.0" encoding="utf-8"?> 
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
         <item android:state_enabled="false" android:drawable="@drawable/camera"/>
         <item android:state_enabled="true" android:state_pressed="true" android:drawable="@drawable/camera_sel" />
         <item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/camera_sel" />
         <item android:state_enabled="true" android:drawable="@drawable/camera"/>
    </selector>

    <Button
        android:id="@+id/cameraButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@drawable/camera_btn" />

Why is the button appearing too large in Android 4.0?

Blumer
  • 5,005
  • 2
  • 33
  • 47

1 Answers1

1

Do you have the png images only in hdpi ? IF you want to support multiple screen sizes, you should provide also ldpi, mdpi, and xhdpi versions of your image.

If the screen of your 4.0 device has other dimensions than your 2.2 / 2.3 devices, this could be the problem.

Check out Android Developer Tutorial for multiple screen sizes

gmazlami
  • 684
  • 2
  • 9
  • 18