我有一个 RelativeLayout
,背景设置为 android:background="@drawable/background"
。
在我的 RelativeLayout 中,我有一个标准按钮,但是当我在运行 3.1 或更高版本的设备上运行该应用程序时,该按钮显示为透明。
我曾尝试将 android:alpha
设置为 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>
确保您也在 list 中正确设置了主题
<application
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/Theme.ApplicationStyle" >
关于Android普通按钮变透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15501214/