perra
perra

Reputation: 37

Android normal button turns transparent

I have a RelativeLayout with a background set with android:background="@drawable/background".

In my RelativeLayout` I have a standard button but when I run the app in devices running 3.1 or higher the button are displayed transparent.

I have tried setting android:alpha to 1 with no luck.

I know I can make a custom background with selector and shapes but there has to be another way.

Anyone else had this problem?

Upvotes: 1

Views: 342

Answers (1)

Rawkode
Rawkode

Reputation: 22592

You'll want to add something like this to your style.xml

Application theme

<style name="ApplicationStyle" parent="android:Theme">
  <item name="android:buttonStyle">@style/MyButtons</item>
</style>

Button style

<style name="MyButtons" parent="@android:style/Widget.Button">
    <item name="android:textSize">16sp</item>
    <item name="android:background">#000000</item>
</style>

Make sure you're setting your theme correctly in the manifest also

<application
    android:allowBackup="true"
    android:icon="@drawable/app_icon"
    android:label="@string/app_name"
    android:theme="@style/Theme.ApplicationStyle" >

Upvotes: 1

Related Questions