•效果展现图
•实现方法
建立一个 $drawable\ resource\ file$,命名为 $shape_circle$;android
在这个 $.xml$ 文件中添加以下代码便可;spa
1 <?xml version="1.0" encoding="utf-8"?> 2 <shape xmlns:android="http://schemas.android.com/apk/res/android" 3 android:shape="oval"> 4 5 <!-- 填充的颜色 --> 6 <solid android:color="#30CCF3"/> 7 <!-- 设置按钮的四个角为弧形 --> 8 <!-- android:radius 弧形的半径 --> 9 <corners android:radius="360dip"/> 10 <!-- padding: Button 里面的文字与Button边界的间隔 --> 11 <padding 12 android:left="10dp" 13 android:top="10dp" 14 android:right="10dp" 15 android:bottom="10dp"/> 16 17 </shape>而后,在 $<Button>$ 中调用 $shape\_circle$ 便可;3d
须要注意的是,要想实现圆形效果,须要把该 $<Button>$ 组件的长宽比设置为 1:1;code
1 <Button 2 android:layout_centerInParent="true" 3 android:layout_width="150dp" 4 android:layout_height="150dp" 5 android:text="我是圆形按钮" 6 android:background="@drawable/shape_circle"/>