Подтвердить что ты не робот

Android CardView со странной границей при прозрачности

У меня проблемы с прозрачностью CardView и card_elevation. Результат использования CardView прозрачен:

enter image description here

Без прозрачности:

enter image description here

То, что я пытаюсь получить, выглядит примерно так:

enter image description here

Вот мой xml:

<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:background="@mipmap/eifell"
    android:padding="10dp"
    tools:context=".MainActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="5dp"
        android:background="@android:color/transparent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:id="@+id/newsCardView"
                android:layout_width="match_parent"
                android:layout_height="175dp"
                card_view:cardBackgroundColor="#602B608A"
                card_view:cardElevation="5dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@android:color/transparent">
                </LinearLayout>

            </android.support.v7.widget.CardView>

        </LinearLayout>
    </ScrollView>

</RelativeLayout>
4b9b3361

Ответ 1

Попробуйте этот код:

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <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:id="@+id/newsCardView"
        android:layout_width="175dp"
        android:layout_height="175dp"
        card_view:cardBackgroundColor="#602B608A"
        card_view:cardCornerRadius="0dp"
        card_view:cardElevation="5dp">

    </android.support.v7.widget.CardView>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:layout_gravity="left|top"
        android:src="@drawable/fake_image" /> //REPLACE THIS WITH YOUR IMAGE
</FrameLayout>

enter image description here

Если это не помогло, укажите полный xml-код вашего макета

Ответ 2

Я знаю, что немного опоздал, но это только из-за повышения карты по умолчанию. Установите это в ноль, чтобы решить вашу проблему.

app:cardElevation="0dp"