我已经找到了几个关于如何通过活动做到这一点的解决方案,但我更愿意坚持使用 xml 进行布局和图形。
我想在具有圆角边缘而不是普通默认角的按钮上设置图像。
XML 样本:
<ImageView
                android:id="@+id/featuredimage"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:clickable="true"
                android:background="@drawable/rounded"
                android:src="@drawable/budlight_sample"
                android:scaleType="centerCrop" />
圆角.XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >
    <corners
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp" >
    </corners>
</shape>