欢迎来到代码驿站!

Android代码

当前位置:首页 > 移动开发 > Android代码

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

时间:2021-04-20 08:54:58|栏目:Android代码|点击:

 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 MIUI通知类短信权限的坑

栏    目:Android代码

下一篇:Android新布局方式ConstraintLayout快速入门教程

本文标题:Android TextView(圆弧)边框和背景实例详解

本文地址:http://www.codeinn.net/misctech/104839.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有