Android在Android UI中绘制圆角矩形

Den*_*sky -1 user-interface android shape

我想在图像上画出形状,我该怎么做?在此输入图像描述

Bha*_*nki 5

使xml可绘制

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <solid android:color="@color/red" />

    <corners android:radius="10dp" />

</shape>
Run Code Online (Sandbox Code Playgroud)

并将此drawable设置为imageview背景

  • 注意:ImageView的高度必须是"2*radius"(在本例中为20dp),以获得所需的"完美圆形"效果. (2认同)