Android-仅具有一个圆角的ImageView

问题描述 投票:1回答:1

我想这样创建ImageView(图像的右侧):

enter image description here

我在CardView布局中使用它,因此我在卡片上有圆角,但是我需要单独创建图像的左下角(或右上角)。

我尝试了几种选择,但没有正常工作。

我该怎么做?你有小费吗?

android imageview android-imageview android-image rounded-corners
1个回答
0
投票

这个简单的可绘制资源文件

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#fff"/>
    <corners android:bottomLeftRadius="30dp" android:topRightRadius="30dp"/>
</shape>

并将绘图文件设置为背景图像视图

<ImageView
            android:id="@+id/imageView"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:background="@drawable/herenamedrawableresourcefile"
            android:layout_gravity="center_horizontal"
            android:src="@drawable/text_logo_fix" />

或您可以这样设置

<LinearLayout
            android:padding="10dp"
            android:layout_marginTop="20dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/herenamedrawableresourcefile">
            <ImageView
                android:id="@+id/imageView"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_gravity="center_horizontal"
                android:src="@drawable/text_logo_fix" />
        </LinearLayout>
© www.soinside.com 2019 - 2024. All rights reserved.