Android的正常按钮变成透明按钮、透明、正常、Android

由网友(狗子爱你)分享简介:我有一个 RelativeLayout的与设置背景的android:背景=@绘制/背景 在我RelativeLayout`我有一个标准的按钮,但是当我运行运行3.1或更高版本的按钮设备的应用程序都显示透明。 In my RelativeLayout` I have a standard button but whe...

我有一个 RelativeLayout的设置背景的android:背景=@绘制/背景

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

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.

我曾尝试 Android的设置:阿尔法 1,没有运气

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.

任何人都有这个问题?

推荐答案

您会想这样的事情添加到您的style.xml

You'll want to add something like this to your 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>

请确保您还正确设置你的主题在清单

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" >
阅读全文

相关推荐

最新文章