View的圆背景以及圆角矩形背景
2016-08-09 11:22
225 查看
这是2个小东西,但是经常用到。总结一下
shape有4种:
有时候设置圆形背景的时候,还会有useLevel这个属性,不知道有什么用。没有也可以运行
1、圆背景
无边缘的圆背景
有边缘的圆背景
源码:
引用:
2、圆角矩形
源码
shape有4种:
<!--android:shape=["rectangle" | "oval" | "line" | "ring"]--> <!--shape的形状,默认为矩形,可以设置为矩形(rectangle)、椭圆形(oval)、线性形状(line)、环形(ring)-->
有时候设置圆形背景的时候,还会有useLevel这个属性,不知道有什么用。没有也可以运行
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" android:useLevel="false"> ...... ...... </shape>
1、圆背景
无边缘的圆背景
有边缘的圆背景
源码:
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > <solid android:color="#00ff00"/> <!--<stroke--> <!--android:width="1dp"--> <!--android:color="@android:color/white"/>--> <size android:width="25dp" android:height="25dp"/> </shape>
引用:
<TextView android:id="@+id/tv_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/design_circle_bg" android:gravity="center" android:text="1" />
2、圆角矩形
源码
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <!--圆角度数--> <corners android:radius="13dp" /> <!--边宽宽度及边宽颜色--> <stroke android:width="1dp" android:color="#ccffffff"/> <!--背景--> <solid android:color="#55000000" /> </shape>
相关文章推荐
- 背景圆角以及图片圆角处理
- android 背景圆角以及图片圆角处理
- android 动态背景的实现以及SurfaceView中添加EditText控件
- android在代码中四种设置控件(以及TextView的文字颜色)背景颜色的方法
- 读书笔记--精通CSS高级Web标准解决方案(四)---CSS背景以及圆角框实现
- 不用css样式表和背景图片实现圆角矩形
- android 自定义圆角ImageView以及锯齿的处理
- Android中View绘制不同状态背景图片原理深入分析以及StateListDrawable使用详解
- 给View设置圆角以及边框
- Android中View(视图)绘制不同状态背景图片原理深入分析以及StateListDrawable使用详解
- (原)带圆角矩形边框的view
- Android中View(视图)绘制不同状态背景图片原理深入分析以及StateListDrawable使用详解
- Android中View(视图)绘制不同状态背景图片原理深入分析以及StateListDrawable使用详解
- android 动态背景的实现以及SurfaceView中添加EditText控件
- Android给TextView设置透明背景、圆角边框
- android view绘制圆角矩形(转)
- 不用css样式表和背景图片实现圆角矩形,超简洁!
- 背景圆角以及图片圆角处理
- IOS开发之TableView以及TableViewCell背景设置
- android 动态背景的实现以及SurfaceView中添加EditText控件