简体   繁体   中英

Round ring button in Android

I want to create a button background (or button itself) that look exactly like the below one.

在此输入图像描述

I'm doing it currently with an image. I tried to create a similar one using the following XML, but it doesn't look as expected.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="oval">
   <solid
     android:color="#f0600000"/>
   <stroke
     android:width="10dp"
     android:color="#FFFF6666"/>
</shape>

Actually I want a round button with 3 pixel shadow and 1/4 width stroke in red color around the white circle. I have not succeeded with the shadow part at all. Thanks for any sort of help.

Well, the solid fills the middle and stroke paints the border. Since you want 3 colors you will have to use 2 drawables, painting white circle over the red circle with grey border. You can then use LayerDrawable to keep these as one unit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM