如何在Android中创建可绘制的环形图形? [英] How to create ring shape drawable in android?
本文介绍了如何在Android中创建可绘制的环形图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用此代码,我只会得到一个边框:
with this code I get just a border:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadius="15dp"
android:thickness="2dp"
android:useLevel="false">
<solid android:color="#4d4d4d" />
</shape>
如何制作如下图所示的环形:
how can I make a ring shape like below image :
推荐答案
具有2dp间隙的2dp外圈:
2dp outer ring with a 2dp gap:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:top="4dp"
android:right="4dp"
android:bottom="4dp"
android:left="4dp">
<shape
android:shape="oval">
<solid android:color="#4d4d4d" />
</shape>
</item>
<item>
<shape
android:shape="oval">
<stroke android:width="2dp"
android:color="#4d4d4d"/>
</shape>
</item>
</layer-list>
这篇关于如何在Android中创建可绘制的环形图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文