0
所以我覺得我錯過了一些東西,但我似乎無法弄清楚這一點。所以我想在CardView的頂部製作一小段顏色,但如果使用框架佈局或任何類型的佈局並設置背景顏色,它會覆蓋CardView的圓角。以下是一些代碼和問題的截圖。提前謝謝!Android CardView頂部顏色同時保持圓角
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
card_view:cardCornerRadius="10dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_gravity="end"
android:background="@color/colorPrimaryDark"
android:clipChildren="true"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/menuCardImage"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_margin="8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="8dp"
android:layout_toRightOf="@+id/menuCardImage"
android:orientation="vertical">
<TextView
android:id="@+id/menuCardName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
編輯: 原來這只是在Android Studio中的顯示問題。當我安裝應用程序它正常工作。
在卡片視圖上嘗試android:backgroundTint =「@ color/colorPrimary」,或者創建一個可繪製的角形半徑與cardview角半徑相同的形狀,並將其設置爲任意視圖的bg – Debu
這是否發生只有棒棒糖? – Zielony