Android 圆角布局 shape.xml的使用

一:使用简介

shape.xml中是用来让某控件、布局边角呈现弧形的一种方式。其原理就是某控件、布局设置其背景参数为shape.xml

二:使用

1:在drawble目录下新建一布局文件

在drawble目录下(最好用文件浏览器打开drawble而不是drawble-24)新建一布局文件,其根元素设置为“shape”;
在这里插入图片描述

2:参数

solid控制其背景颜色

<solid
        android:color="#EBE8E8"/>

corner控制其弧度半径

<corners
        android:topLeftRadius="7dp"
        android:topRightRadius="7dp"
        android:bottomRightRadius="7dp"
        android:bottomLeftRadius="7dp"/>

stroke控制其边缘宽度、颜色

<stroke
        android:width="1dp"
        android:color="#1893C9" />

示例文件
shape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid
        android:color="#EBE8E8"/>

    <corners
        android:topLeftRadius="7dp"
        android:topRightRadius="7dp"
        android:bottomRightRadius="7dp"
        android:bottomLeftRadius="7dp"/>

    <stroke
        android:width="1dp"
        android:color="#1893C9" />

</shape>

3:应用

XML引用:
设置android:background=""来应用;

Java应用:
使用setBackground()来应用。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值