android TextView加边框&drawable开发


为TextView加边框,需要在drawable建xml文件,里面设置shape来设置文本框的特殊效果。
效果一:

[html]   view plain  copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" >  
  3.     <!-- 实心 -->  
  4.     <solid android:color="@android:color/white" />  
  5.     <!-- 边框 -->  
  6.     <stroke  
  7.         android:width="0.5dp"  
  8.         android:color="@android:color/white" />  
  9.     <!-- 圆角 -->  
  10.     <corners android:radius="3dp" />  
  11.     <!-- 边距 -->  
  12.     <padding  
  13.         android:bottom="5dp"  
  14.         android:left="5dp"  
  15.         android:right="5dp"  
  16.         android:top="5dp" />  
  17.     <!-- 渐变 -->  
  18.     <gradient  
  19.         android:angle="270"  
  20.         android:endColor="#FFFF782"  
  21.         android:startColor="#13C7AF" />  
  22. </shape>  
基本上常用的就这几种,要达到很好的效果,需要细致地调整。

下面是要在用到这个shape的TextView设置背景即可。

Android:background="@drawable/border_write" 
效果。


效果二:

drawable文件如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="3dp"
        />
    <padding
        android:bottom="@dimen/x8"
        android:left="@dimen/x8"
        android:right="@dimen/x8"
        android:top="@dimen/x8" />
    <stroke
        android:width="@dimen/x3"
        android:color="#edc831"
        />
</shape>

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值