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 :
A ShapeDrawable takes a Shape object and manages its presence on the screen. If no Shape is given, then the ShapeDrawable will default to a RectShape . This object can be defined in an XML file with the <shape> element.
Shape root element defines that this is a ShapeDrawable. 1.) Shape type You can specify the type of a shape using android:shape XML attribute in the shape tag. If you don’t specify the shape, the default rectangle type is selected. Other available shapes are oval, line and ring.
First create a new drawable resource file. Right click on res/drawable > New > Drawable resource file > give your file a name > use shape as a root element > click Ok Shape root element defines that this is a ShapeDrawable. 1.) Shape type You can specify the type of a shape using android:shape XML attribute in the shape tag.
Shape. Shape is used to define custom shape in android drawable resource. It is used in both selector and layer-list element. It has below properties. Android:shape : Value can be “line”, “rectangle”, “oval” or “ring”.
Shape, selector, and layer-list are usually used to create custom drawable resources in android development. Those three XML elements can save a lot of UI resources and time if being used properly. This article will show you how to use them correctly. 1. Custom Drawable File Overview.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With