源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android TextView(圆弧)边框和背景实例详解

  • 时间:2022-02-25 22:41 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android TextView(圆弧)边框和背景实例详解
[b] Android TextView 圆弧[/b] 效果图: [img]http://files.jb51.net/file_images/article/201611/20161122143930208.png?20161022143952[/img] [img]http://files.jb51.net/file_images/article/201611/20161122144002461.png?20161022144024[/img] 布局代码:
<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文件实现 [img]http://files.jb51.net/file_images/article/201611/20161122144002461.png?20161022144024[/img] 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、[img]http://files.jb51.net/file_images/article/201611/20161122143930208.png?20161022143952[/img]
<?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> 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部