Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create ring shape drawable in android?

Tags:

android

shape

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 :

enter image description here

like image 700
S.M_Emamian Avatar asked Jun 05 '15 21:06

S.M_Emamian


People also ask

What is drawable shape android?

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.

How do I make a shape drawable in Android?

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.

How to create a shapedrawable in Android Studio?

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.

What is the use of shape in Android?

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”.

How to create custom drawable resources in Android development?

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.


1 Answers

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> 
like image 61
tachyonflux Avatar answered Oct 03 '22 06:10

tachyonflux