本文共 986 字,大约阅读时间需要 3 分钟。
In this tutorial you will learn how to create a round button in android.
在本教程中,您将学习如何在android中创建圆形按钮。
Shape drawable resource is used to define shape of a view. Below I have shared an example to to make a circle button.
形状可绘制资源用于定义视图的形状。 下面我分享了一个制作圆圈按钮的示例。
Create a xml file inside res/drawable folder.
在res / drawable文件夹中创建一个xml文件。
round_button.xml
round_button.xml
shape: Defines shape of view. It can be rectangle, oval, line and ring. In this case we are using oval shape to make the button circular.
shape:定义视图的形状。 它可以是矩形,椭圆形,线形和环形。 在这种情况下,我们使用椭圆形使按钮变为圆形。
stroke: Defines boundary of shape.
笔触:定义形状的边界。
solid: Defines background color of shape.
实体:定义形状的背景色。
size: Defines size of shape.
size:定义形状的大小。
Now set this xml as background of the button.
现在,将此xml设置为按钮的背景。
The button will look like:
该按钮将如下所示:
You can customize its color and size according to your need.
您可以根据需要自定义其颜色和大小。
翻译自:
转载地址:http://lrggb.baihongyu.com/