android中如何给button加圆角

来源:互联网 发布:怎么举报淘宝卖家骂人 编辑:程序博客网 时间:2024/06/05 16:38
[html] view plain copy
  1. //round_corner_bg.xml  
  2.   
  3. <?xml version="1.0" encoding="UTF-8"?>  
  4. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  5.     android:shape="rectangle" >  
  6.     <!-- 填充的颜色 -->  
  7.     <solid android:color="#ff000000" />  
  8.     <!-- 设置矩形的四个角为弧形 -->  
  9.     <!-- android:radius 弧形的半径 -->  
  10.     <corners android:radius="7dip" />  
  11. </shape>  


layout中给button加上background属性

android:background="@drawable/round_corner_bg"

 

上述方法也适用于其他控件

0 0