圆角边框,渐变背景的Textview
2017-01-10 15:37
190 查看
在默认情况下,TextView是不带边框的,如果想为Textview添加边框,只能通过为它设置一个背景Drawable,改Drawble只是一个边框,这样就实现了带边框的TextView
第一步:创建shape XML文件 border.xml
第二步 在TextView中引入背景border.xml
效果图如下:
![](https://img-blog.csdn.net/20170110152303907?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY3NqNzMxNzQyMDE5/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
设置圆角渐变的TextView
第一步:在Drawable创建bg.xml 文件
如下所示
第二步:在TextView中引入
效果图如下:
第一步:创建shape XML文件 border.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <!--设置背景颜色为橙色--> <solid android:color="#daa447"></solid> <!--设置边框颜色为红色--> <stroke android:width="4dp" android:color="#f00"></stroke> </shape>
第二步 在TextView中引入背景border.xml
<TextView android:textSize="50sp" android:background="@drawable/border" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="带边框的文本" />
效果图如下:
设置圆角渐变的TextView
第一步:在Drawable创建bg.xml 文件
如下所示
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!--设置圆角的半径--> <corners android:radius="50dp"></corners> <!--指定使用渐变背景色 颜色从红色-绿色-蓝色--> <gradient android:centerColor="#0f0" android:endColor="#00f" android:startColor="#f00"></gradient> </shape>
第二步:在TextView中引入
<TextView android:textSize="50sp" android:background="@drawable/bg1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="圆角渐变" />
效果图如下:
相关文章推荐
- android 圆角边框、渐变背景的TextView
- android 圆角边框、渐变背景的TextView
- 《疯狂安卓讲义》P86 -- 实例:圆角边框、渐变背景的TextView
- 如何用控件的CALayer 的特性创建 圆角界面,边框,和设置背景
- 主题:转:shape 渐变!描边!圆角!漂亮的自定义背景
- CSS3.0特性—图像的背景 背景透明颜色 图像的透明 颜色的渐变 圆角 阴影
- android 开发技巧(10)--为背景添加圆角边框
- 【控件扩展】带圆角、边框、渐变的panel
- 蛙蛙推荐:css背景图片固定居中,div阴影,背景半透明,div圆角,DIV渐变
- css3 文字流光渐变 背景模糊 边框两边伸展
- 代码设置TextView、Button等控件圆角边框背景颜色
- 如何创建[圆角、边框色彩渐变、边框宽度自定义]窗体
- (转)#小美化#Android给TextView设置透明背景、圆角边框
- UITextView的创建/背景图片/边框和颜色/圆角等
- Android给TextView设置透明背景、圆角边框
- android 背景边框变圆角
- TextView属性之圆角And渐变背景
- android 圆角渐变背景xml文件
- LinearLayout设置白色背景、灰色边框、倒圆角