像iphone一样将android TextView 做成圆角的

来源:互联网 发布:淘宝店铺佣金怎么设置 编辑:程序博客网 时间:2024/05/16 05:42

方法一:做个圆角的背景图片加上去,比较老套。

 

方法二:在项目drawable下创建textview.xml内容如下:

              

             <?xml version="1.0" encoding="utf-8"?>

              <shape xmlns:android="http://schemas.android.com/apk/res/android">
               <solid android:color="#ffffffff" />
                 <corners android:radius="10dp" />
                   <padding android:left="5dp" android:top="5dp" 
                      android:right="5dp" android:bottom="5dp" />
             </shape>

          

              在onCreate方法中加入: TextView tv = (TextView) findViewById(R.id.textView1);
                                                   tv.setBackgroundResource(R.drawable.textview);

            

               或者在TextView属性中设置:android:background="@drawable/textview"

 

          如此简单!!!

将EditText做成圆角的只需在xml加入一句话<corners  android:radius="10dip"/>,然后再EditText属性中设置为背景,即可。方法同上.

原创粉丝点击