Android如何设置圆角按钮

1. res目录下的drawable目录下新建shape.xml文件

[html]  view plain  copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="rectangle" >  
  4.   
  5.     <!-- 填充的颜色 -->  
  6.     <solid android:color="#FF065E8D" />  
  7.   
  8.     <!-- 设置按钮的四个角为弧形 -->  
  9.     <!-- android:radius 弧形的半径 -->  
  10.     <corners android:radius="15dip" />  
  11.   
  12.     <!-- padding:Button里面的文字与Button边界的间隔 -->  
  13.     <padding  
  14.         android:bottom="10dp"  
  15.         android:left="10dp"  
  16.         android:right="10dp"  
  17.         android:top="10dp" />  
  18. </shape>  

2.在布局文件中调用。

[html]  view plain  copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <Button  
  8.         android:id="@+id/roundButton"  
  9.         android:layout_width="wrap_content"  
  10.         android:layout_height="wrap_content"  
  11.         android:background="@drawable/shape"  
  12.         android:text="圆角按钮" />  
  13. </LinearLayout>  

nvisible:不显示,但保留所占的空间

visible:正常显示

gone:不显示,且不保留所占的空间

XML里:

android:visibility="visible"

代码里,如Button

btn.setVisibility(View.VISIBLE);


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值