Почему отсечение CardView не работает на уровне API ниже 21? - PullRequest
0 голосов
/ 05 января 2019

У меня есть следующий код:

<?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 и выше все в порядке.


визуальный:

enter image description here

1 Ответ

0 голосов
/ 05 января 2019

Я полагаю, что в этом 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" тоже

...