我正在尝试在 Android 中使用 XML 创建一个只有边框的圆形:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<stroke android:width="1dp"
android:color="#000000"/>
</shape>
我使用的代码已发布在上面。然而,我得到的是一个实心圆盘而不是一个环形。我想使用仅 XML 而不是 canvas 来获得输出。我做错了什么?
谢谢。
编辑: 由于下面的答案,我成功解决了问题。这是我的最终代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:useLevel="false" >
<solid android:color="@android:color/transparent" />
<size android:width="100dp"
android:height="100dp"/>
<stroke android:width="1dp"
android:color="#FFFFFF"/>
</shape>
android:thicknessRatio="2"
设置为一个闭环(Nexus 5,棒棒糖版本)。 - David