Android普通按钮变为透明

时间:2013-03-19 13:44:04

标签: android android-layout

我的RelativeLayout背景设置为android:background="@drawable/background"

在我的RelativeLayout`中我有一个标准按钮但是当我在运行3.1或更高版本的设备中运行应用程序时,按钮显示为透明。

我尝试将android:alpha设置为1而没有运气。

我知道我可以使用选择器和形状制作自定义背景,但必须采用另一种方式。

其他人有这个问题吗?

1 个答案:

答案 0 :(得分:1)

您需要在style.xml中添加类似的东西

应用主题

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

按钮样式

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

确保您在清单中正确设置主题

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