简体   繁体   English

Android中的圆环按钮

[英]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创建一个类似的,但它看起来不像预期的那样。

<?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. 实际上我想要一个圆形按钮,在白色圆圈周围有3像素阴影和1/4宽度笔划红色。 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. 由于您需要3种颜色,因此必须使用2个绘图,在带有灰色边框的红色圆圈上绘制白色圆圈。 You can then use LayerDrawable to keep these as one unit 然后,您可以使用LayerDrawable将这些作为一个单元保留

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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