我有以下代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_margin="20dp"
android:clipChildren="true"
app:cardCornerRadius="50dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_marginLeft="9dp"
android:background="#f22" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
我要删除CardView
之外的多余垂直线。实际上,我想要垂直的半径线。
在Android api 21及更高版本中,一切正常。
视觉:
答案 0 :(得分:0)
我认为不需要那个LinearLayout(您的卡片的父母)。因此只需将其删除并使其真正成为卡。
<android.support.v7.widget.CardView
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="140dp"
android:layout_margin="20dp"
android:clipChildren="true"
app:cardCornerRadius="50dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_marginLeft="9dp"
android:background="#f22" />
</RelativeLayout>
</android.support.v7.widget.CardView>
也尝试使用app:cardUseCompatPadding="true"
和android:clipChildren="true"