iis服务器助手广告
返回顶部
首页 > 资讯 > 移动开发 >Android TextView(圆弧)边框和背景实例详解
  • 772
分享到

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

Android 2022-06-06 05:06:52 772人浏览 泡泡鱼
摘要

 Android TextView 圆弧 效果图: 布局代码: <TextView Android:id="@+id/product

 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 TextView设置背景色与边框的方法详解android开发教程之view组件添加边框示例Android 去掉自定义dialog的白色边框的简单方法Android中EditText如何去除边框添加下划线Android实现带有边框的ListView和item的方法Android 圆角边框的实现方式汇总android dialog边框去除白色边框实现思路及代码Android实现代码画虚线边框背景效果Android布局实现圆角边框效果Android实现为GridView添加边框效果


--结束END--

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

本文链接: https://www.lsjlt.com/news/23175.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作