Creating circle inside circle shape in android using xml file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Larger blue circle in back -->
<item>
<shape android:shape="oval">
<solid android:color="#f00"/>
<size
android:width="15dp"
android:height="15dp"/>
</shape>
</item>
<!-- Smaller red circle in front -->
<item>
<shape android:shape="oval">
<!-- transparent stroke = larger_circle_size - smaller_circle_size -->
<stroke android:color="@android:color/transparent"
android:width="10dp"/>
<solid android:color="#fff"/>
<size
android:width="1dp"
android:height="1dp"/>
</shape>
</item>
<item>
<shape android:shape="oval">
<!-- transparent stroke = larger_circle_size - smaller_circle_size -->
<stroke android:color="@android:color/transparent"
android:width="11dp"/>
<solid android:color="#f00"/>
<size
android:width="1dp"
android:height="1dp"/>
</shape>
</item>
</layer-list>
Above code will generate shape given below
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Larger blue circle in back -->
<item>
<shape android:shape="oval">
<solid android:color="#f00"/>
<size
android:width="15dp"
android:height="15dp"/>
</shape>
</item>
<!-- Smaller red circle in front -->
<item>
<shape android:shape="oval">
<!-- transparent stroke = larger_circle_size - smaller_circle_size -->
<stroke android:color="@android:color/transparent"
android:width="10dp"/>
<solid android:color="#fff"/>
<size
android:width="1dp"
android:height="1dp"/>
</shape>
</item>
<item>
<shape android:shape="oval">
<!-- transparent stroke = larger_circle_size - smaller_circle_size -->
<stroke android:color="@android:color/transparent"
android:width="11dp"/>
<solid android:color="#f00"/>
<size
android:width="1dp"
android:height="1dp"/>
</shape>
</item>
</layer-list>
Above code will generate shape given below
Android example
ReplyDelete