Android TextView(圆弧)边框和背景实例详解
更新时间:2016年11月22日 14:41:09 投稿:lqh
这篇文章主要介绍了 Android TextView(圆弧)边框和背景实例详解的相关资料,这里提供了实现代码和实现效果图,需要的朋友可以参考下
Android TextView 圆弧
效果图:
布局代码:
<TextView android:id="@+id/product_tag" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:singleLine="true" android:textSize="10sp" android:textColor="@color/label_orange" android:layout_marginLeft="10dp" android:background="@drawable/shape_label_orange" android:text="标签"/>
样式代码:
弧度和背景主要靠background中的.xml文件实现
1、
<?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="0.5dp" android:color="@color/label_orange"/> <!-- 圆角 --> <corners android:radius="3dp"/> <!-- 边距 --> <padding android:top="2dp" android:bottom="2dp" android:left="6dp" android:right="6dp"/> </shape>
2、
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" android:useLevel="false"> <!-- 实心 --> <solid android:color="@color/label_round_orange" /> <!-- 圆角 --> <corners android:radius="360dp" /> <!-- 边距 --> <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" /> <!-- 大小 --> <size android:width="15dp" android:height="15dp" /> </shape>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
相关文章
Android中的RecyclerView新组件初步上手指南
RecyclerView是Android L版本开始采用的一个组件,被人们认为用来代替传统的ListView,下面我们就一起来看一下Android中的RecyclerView新组件初步上手指南2016-06-06android popuwindow点击外部窗口不消失的实例
下面小编就为大家带来一篇android popuwindow点击外部窗口不消失的实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-04-04Android中Intent传递对象的两种方法Serializable,Parcelable
这篇文章主要介绍了Android中的传递有两个方法,一个是Serializable,另一个是Parcelable,对intent传递对象的两种方法感兴趣的朋友一起学习吧2016-01-01
最新评论