Search code examples
androidandroid-layoutandroid-holo-everywhere

Android - why does the background image make the buttons look so strange?


I am trying to use the Android Holo.Light theme and for some reason when I add a background image, it makes the buttons look very strange and see-through. Here is a screen shot:

enter image description here

Would anyone know why this happens? It looks very strange. Is it meant to be like that? Or am I doing something incorrectly?

When I had just Light as my theme, the same image was not see-through.

Thank you!


Solution

  • The default for Holo buttons are slightly opaque. Just set a background drawable for them!

    Here's an example of a gray button with a 1px outline. Includes the pressed state. You will set this on the button with "android:background="@drawable/gray_btn":

    @drawable/gray_btn.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" >
        <shape>
            <solid
                android:color="#ffffff" 
                />
            <stroke
                android:width="1dp"
                android:color="#E3E3E3" />
            <corners
                android:radius="4dip" />
    
        </shape>
    </item>
    <item>
        <shape>
            <solid
                android:color="#edeff1" 
                />
            <stroke
                android:width="1dp"
                android:color="#E3E3E3" />
            <corners
                android:radius="4dip" />
    
        </shape>
    </item>