изображение в картридже с верхним радиусом без углового радиуса - PullRequest
0 голосов
/ 16 мая 2018

У меня есть recyclerView, который внутри cardView имеет ImageView, и его высота составляет 70%. Так что я дал угловой радиус для cardView. Показана нижняя часть радиуса cardView, но проблема в том, что верхняя часть, покрытая изображением, не принимает угловой радиус cardView.

Я пробовал эти вопросы: вопрос , вопрос . Но проблема остается прежней.

XML

<?xml version="1.0" encoding="utf-8"?>

<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:id="@+id/card_view"
    android:layout_width="wrap_content"
    android:layout_height="@dimen/_200sdp"
    android:layout_marginRight="@dimen/_15sdp"
    android:layout_marginLeft="15dp"
    android:layout_marginTop="15dp"
    card_view:cardCornerRadius="@dimen/_20sdp"
    card_view:cardBackgroundColor="@color/White"
    android:layout_marginBottom="@dimen/_10sdp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/party_image"
            android:layout_width="@dimen/_160sdp"
            android:layout_height="@dimen/_140sdp"
            android:adjustViewBounds="true"
            android:scaleType="centerCrop" />

        <TextView
            android:id="@+id/party_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="13sp"
            android:text="John Doe"
            android:textColor="@color/colorPrimary"
            android:gravity="center"
            android:paddingBottom="8dp"
            android:paddingTop="8dp"
            />

    </LinearLayout>

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

Мое выходное изображение: https://imgur.com/a/FequXmj

1 Ответ

0 голосов
/ 16 мая 2018

Попробуйте это ..

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_view"

    android:layout_width="match_parent"
    android:layout_height="120dp"
    android:layout_gravity="center"

    android:layout_margin="8dp"
    android:background="@drawable/shape"

    android:elevation="4dp">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:elevation="4dp"
        app:cardCornerRadius="8dp">

        <ImageView
            android:id="@+id/thumbnaill"
            android:layout_width="160dp"
            android:layout_height="140dp"
            android:layout_gravity="left"
            android:background="@drawable/sa"
            android:scaleType="fitXY"
            />
    </android.support.v7.widget.CardView>
</FrameLayout>

А у тебя Drawable сделай xml shape.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" android:padding="10dp">
    <!-- you can use any color you want I used here gray color-->
    <solid android:color="#ffffff"/>
    <corners android:radius="8dp"/>
    <!--<stroke android:width="0.5dp" android:color="@color/darker_gray"/>-->
</shape>

Это будет выглядеть так ... Результат

enter image description here

...