Android的View加边框

来源:互联网 发布:12 fan club动作数据 编辑:程序博客网 时间:2024/06/08 11:54

以Textview为例

在Drawable里新建XML

 textview_bar.xml

<?xml version="1.0" encoding="UTF-8"?>  <shape xmlns:android="http://schemas.android.com/apk/res/android" >        <solid android:color="@android:color/white" />        <stroke          android:width="1dip"          android:color="@android:color/black" />    </shape>  


然后在定义控件时

  1. <TextView  
  2.     android:layout_width="wrap_content"  
  3.     android:layout_height="wrap_content"  
  4.     android:background="@drawable/textview_bar"  
  5.     android:text="SDCard--------------------↓" />  

其它控件均适用