【发布时间】:2020-08-02 20:29:11
【问题描述】:
我对 CardView 背景不透明度有疑问。我想让我的背景半透明,但我有一个奇怪的错误,一直在发生。最好的解释是我的程序截图。
我希望此布局全部采用相同的半透明颜色。相反,出现的是这种半透明的颜色,里面有更透明的矩形。我不知道如何从我的布局中删除这个矩形。代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="15dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:cardBackgroundColor="#66000000">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="15dp">
<ImageView
android:id="@+id/flagImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:fontFamily="@font/changa_light"
android:scaleType="fitXY"
app:srcCompat="@mipmap/ic_launcher" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/flagTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TEST"
android:textColor="#ffffff"
android:gravity="center"
android:fontFamily="@font/changa_light"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</RelativeLayout>
【问题讨论】:
标签: android xml android-studio android-layout