Relativelayout透明度问题

Relativelayout transparency issue

我正在创建相对布局,但我有透明度问题。

模拟器截图:

为什么Button是透明的?这是我的 xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="34dp"
        android:layout_marginTop="41dp"
        android:text="TextView" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/textView1"
        android:layout_alignTop="@+id/textView1"
        android:text="Button" />

</RelativeLayout>

设置按钮背景android:background="@android:color/transparent"使其透明或

`android:background="@color/myColor" 任何其他颜色

Why Button is transparent ?

因为按钮的默认背景可绘制对象是半透明的。如果要更改它,请将另一个可绘制对象设置为按钮的 android:background

为什么 TextViewButton 彼此重叠,因为 layout_align... 属性对齐两个视图的相应边缘。