Android 设置背景图像时,按钮显示为透明。我想要实心钮扣

Android 设置背景图像时,按钮显示为透明。我想要实心钮扣,android,Android,当使用一个小gif作为布局的背景平铺时,我发现我的按钮看起来是透明的,这不是我想要的,我也没有设置任何透明度参数(除非背景gif是透明的?) 我的XML是: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:lay

当使用一个小gif作为布局的背景平铺时,我发现我的按钮看起来是透明的,这不是我想要的,我也没有设置任何透明度参数(除非背景gif是透明的?)

我的XML是:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="2"
    android:background="@drawable/backgroundrepeat"
    >
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scrollbars="vertical"
    android:id="@+id/scrollview1"
    android:layout_weight="2"
    android:layout_marginLeft="20dp"
   android:layout_marginRight="20dp">
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="match_parent"
    android:id="@+id/textview"
    android:scrollbars="vertical"
    android:textColor="@android:color/black"
    />
   </ScrollView>
<Button android:text="Connect To Phidget" android:id="@+id/connect_button" android:layout_width="match_parent" 
    android:layout_height="wrap_content"
    android:enabled="false"
    android:layout_weight="0"
    android:layout_marginLeft="20dp"
   android:layout_marginRight="20dp"
   android:background="@null"
    ></Button>
</LinearLayout>

可拉伸瓷砖为:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/original10" 
    android:tileMode="repeat"
     />

有人能帮忙吗?谢谢

添加此标签按钮

android:background="@android:drawable/btn_default"
“添加此标记”按钮

android:background="@android:drawable/btn_default"

嗯。然后删除标记:

android:background="@null"

这使它以您描述它的方式变得透明。

好的。然后删除标记:

android:background="@null"

这使得它的描述方式变得透明。

根据Android开发者文档,使用GIF图像是不被鼓励的

虽然他们没有详细说明原因,但我认为这是由于它的多层性。但我玩过GIF图像,遇到了和你类似的错误


因此,我建议您将GIF图像导出为PNG并尝试使用它。您可以使用任何工具,如Gimp或IrfanViewer。

根据Android开发者文档,不鼓励使用GIF图像

虽然他们没有详细说明原因,但我认为这是由于它的多层性。但我玩过GIF图像,遇到了和你类似的错误


因此,我建议您将GIF图像导出为PNG并尝试使用它。您可以使用任何工具,如Gimp或IrfanViewer。

建议使用png。你不能转换它吗?同意,GIF是一种专有格式,应该避免。我试过png,但还是一样的。显然,必须有一个XML属性来设置透明度/alpha?解析它!我忘了按钮是禁用的,android必须改变透明度!建议使用png。你不能转换它吗?同意,GIF是一种专有格式,应该避免。我试过png,但还是一样的。显然,必须有一个XML属性来设置透明度/alpha?解析它!我忘了按钮是禁用的,android必须改变透明度!对不起,把那个忘在里面了。我已经把它拿出来了,因为我把它放进去是为了试一下,修补匠们担心,把它放错了。我已经把它拿出来了,因为我把它放进去,试着修补一下,结果是一个坚固的黑匣子。我想要没有透明度的默认按钮样式。真不敢相信这么难做到!这将导致一个实心黑盒。我想要没有透明度的默认按钮样式。真不敢相信这么难做到!