• 圆角边框和渐变


    Demo2aasrcmain esdrawableg_border.xml

    1 <?xml version="1.0" encoding="utf-8"?>
    2 <shape xmlns:android="http://schemas.android.com/apk/res/android">
    3     <!--设置背景色为透明色-->
    4     <solid android:color="#0000"/>
    5     <!--设置红色边框-->
    6     <stroke android:width="4dp" android:color="#f00"/>
    7 </shape>

    Demo2aasrcmain esdrawableg_border2.xml

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <shape xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:shape="rectangle">
     4     <!--指定圆角矩形的4个圆角的半径-->
     5     <corners
     6         android:bottomLeftRadius="5dp"
     7         android:bottomRightRadius="20dp"
     8         android:topLeftRadius="20dp"
     9         android:topRightRadius="5dp" />
    10     <!--指定边框线条的宽度和颜色-->
    11     <stroke
    12         android:width="4dp"
    13         android:color="#f0f" />
    14     <!--指定使用渐变背景色,使用sweep类型的渐变(红绿蓝)-->
    15     <gradient
    16         android:centerColor="#0f0"
    17         android:endColor="#00f"
    18         android:startColor="#f00"
    19         android:type="sweep" />
    20 </shape>

    Demo2aasrcmain eslayoutactivity_main.xml

     1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     2     xmlns:tools="http://schemas.android.com/tools"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent"
     5     android:orientation="vertical"
     6     tools:context=".MainActivity">
     7 
     8     <!--通过background指定背景-->
     9     <TextView
    10         android:layout_width="match_parent"
    11         android:layout_height="wrap_content"
    12         android:text="带边框的文本"
    13         android:textSize="24sp"
    14         android:background="@drawable/bg_border"/>
    15     <TextView
    16         android:layout_width="match_parent"
    17         android:layout_height="wrap_content"
    18         android:text="圆角边框,渐变背景的文本"
    19         android:textSize="24sp"
    20         android:background="@drawable/bg_border2"/>
    21 
    22 </LinearLayout>
  • 相关阅读:
    [原创]快速排序(C++版)
    连接mysql8.0时报错的问题
    关于idea无法使用搜狗输入法打出汉字的解决方案(转)
    bootStrap select组件相关问题
    idea 项目可以运行但是jsp中url报红的问题
    idea 项目启动找不到页面问题和run/debug只能启动一个的问题
    form序列化到后台中文乱码
    在js中获取bootStrap table 的属性
    三元运算符,多条件时判断
    Spring获取日期时间差8小时问题解决
  • 原文地址:https://www.cnblogs.com/LY1124/p/4671980.html
Copyright © 2020-2023  润新知