强大的SHAPE资源
来源:互联网 发布:java 单引号 转义 编辑:程序博客网 时间:2024/04/30 11:14
shape资源可以定义形状、渐变、边距、边框、圆角(你越来越像一头猪了——“形渐变变圆” )今使用shape资源实现一个圆角矩形风格的TextView
定义shape资源:
<?xml version="1.0" encoding="utf-8"?>
<!--shape属性的可选项还有:line,ring,oval-->
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<!--45度渐变色-->
<gradient android:startColor="#ffff0000" android:endColor="#80ff00ff" android:angle="45"/>
<padding android:top="7dp" android:bottom="7dp" android:left="7dp" android:right="7dp" />
<stroke android:width="2dp" android:color="#ffffff"/>
<!--圆角半径8-->
<corners android:radius="8dp"/>
</shape>
在布局中使用shape:
<TextView
android:id="@+id/tv_shape"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape"
android:text="what a shape!"/>
在代码中动态使用:
Drawable shape=getResources().getDrawable(R.drawable.shape);
TextView tv=findViewById(R.id.tv_shape) ;
tv.setBackground(shape);
0 0
- 强大的SHAPE资源
- Drawable资源--Shape的使用
- Android DrawableShape资源的用法,Shape属性,Shape开发
- selector和shape静态资源的使用
- android shape 资源的学习笔记
- Android-关于资源文件shape的详解
- android资源shape详解
- Drawable资源(包含shape)
- android shape资源
- 图片资源之shape
- ShapeDrawable资源(shape)
- 形状资源(shape)
- Android资源文件-Shape
- Android自定义shape资源
- shape资源介绍
- Android Shape 资源文件
- android shape简单资源
- 详解资源文件Drawable下面的shape标签
- (解题报告)HDU2013---蟠桃计
- charles使用教程
- iOS- 如何集成支付宝
- 使用CLIP资源制作一个进度条
- git学习笔记——远端
- 强大的SHAPE资源
- (解题报告)HDU2014---青年歌手大奖赛_评委会打分
- alrtbuilder.dialog使用以及两种上下文比较
- PopupWindow
- flexpaper常用参数
- leetcode -- Partition List -- 常见题型重点
- Ubuntu设置环境变量
- IOS开发中的微信支付
- 安卓无标题主题风格设置