[英]How to Make GridLayout Background Transparent?
我在回收器視圖中實現GridLayout,並從drawable文件夾中加載了Images。
如您所見,背景為白色,我想使其透明,此布局的XML代碼為
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000"
android:id="@+id/card"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="2dp"
card_view:cardUseCompatPadding="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:scaleType="centerCrop" />
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="Abcd"
android:textSize="18dp"
android:textStyle="bold"
android:textAllCaps="true"
android:textColor="#ffffff"
android:layout_marginTop="140dp"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
我嘗試了很多事情,例如:
不過,我仍然無法獲得透明的背景。 誰能建議一種新方法?
另外,使用的圖像是具有透明背景的矢量圖像。
更新
現在可以使用了,感謝@Adley
我只需要刪除我正在使用的卡布局並將其轉換為正常的相對布局
編輯:
嘗試將card_view:cardBackgroundColor="@android:color/transparent"
到根視圖(CardView)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.