android 自定义控件——(一)圆角按钮
----------------------------------矩形或圆角类型(源代码下有属性解释)-----------------------------------------------------
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABDgAAAGJCAMAAABYYHPKAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjNENkREQjgwOUY0MjExRTY4RjMzRDg3NTE2NUJGRkNEIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjNENkREQjgxOUY0MjExRTY4RjMzRDg3NTE2NUJGRkNEIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6M0Q2RERCN0U5RjQyMTFFNjhGMzNEODc1M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DJPk+RA6GFOCYqcYUjMLIZ/BRqEU9czb4VIMkUi3VRuSX0Kbg5EriQcCiTlZntg0W/eOpKjucAkkqJ2A8r+xcPtmfimKjEF47jyS0ptBI0yiGXcvQ5kDT2S40t1x9cCUlbk8cXFQ5tsrKwPWg8v+zjXFkgKdz0mZvt4PZCnBOVOMOhTlaWPvxYLTJ/Bbk6i2uCAVdcfVa1tc0Wrf7361J8E5V4w3E8Ob4bXDlYs5VDlivrsvJK6rnHG3DlDNSX5GXVVdq316K1g5XgRpzdiDccSjk21rf3fsz4ZQBJxz/zY297fWN88vhiw3E8MTU7v7QwujDNewAkm2ll012an52aOL7ocBwHwuqg4+OPd0W8DUAyKXr346M63AgHji8+HNqgQ1pa+L62U8SEBUiWSUrRztr3hSXpHMONc4ZDGXRMz6wv7x38+HG/qId3BLjqeoru//hxsLe8PjN9juHGecOhDjo2paWdzwsf3o7uBYuKBgf9DD6AqzfM8A8OFhUF90bffghtB6W56XMNN84fjuPA5NTWjBT8sri8srr39mAUwJV08HZvdWV5Z0mamR0PTwSOLzccajpGxqc3N+bH1Hp81q2EhAUAlyK0IrbGd8uLO5ovwbH5jc3p8ZFzZ+NvhEOLx8TkyNT0rGJuY1caA3A1SNLuzNymumlOj0+NTE4EAoG/ssn/nXCIfCj9CIfDIwCulPCkmoy/uK3/1XAASBOEAwDhAEA4ABAOAIQDAOEAAMIBgHAAIBwACAcAwgEAhAMA4QBAOAAQDgCEAwAIBwDCAYBwACAcAAgHAMIBAIQDAOEAQDgAJL3/CzAApq/gj6HT+TYAAAAASUVORK5CYII=" alt="" width="322" height="117" />
一、shape 样式:(在drawable新建--》new--》Drawable resource file 并把原父级标签selector改为shape )
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> <solid android:color="#4ec5ff" />
<padding
android:bottom="12dp"
android:left="12dp"
android:right="12dp"
android:top="12dp" />
<corners android:radius="10dp" />
<stroke
android:width="2dp"
android:color="#ffffff"
android:dashGap="270dp" /> </shape>
二、style 样式:
<style name="rectangle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">15sp</item>
<item name="android:textColor">#ffffff</item>
<item name="android:background">@drawable/buttonstyle</item>
</style> 三、Button控件调用style样式:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.ly.blogtest.MainActivity"> <Button
android:id="@+id/button"
style="@style/rectangle"
android:text="@string/btn1" />
</RelativeLayout>
----------------------------------矩形或圆角类型-----------------------------------------------------
----------------------------------android:shape属性指定形状------------------------------
- rectangle: 矩形,默认的形状,可以画出直角矩形、圆角矩形、弧形等
- oval: 椭圆形,用得比较多的是画正圆
- line: 线形,可以画实线和虚线
- ring: 环形,可以画环形进度条
----------------------------------android:shape属性指定形状------------------------------
----------------------------------shape的属性标签-----------------------------------------
<shape>
<!-- 实心 -->
<solid android:color="#ff9d77"/>
<!-- 渐变 -->
<gradient
android:startColor="#ff8c00"
android:endColor="#FFFFFF"
android:angle="270" />
<!-- 描边 -->
<stroke
android:width="2dp"
android:color="#dcdcdc" />
<!-- 圆角 -->
<corners
android:radius="2dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
solid: 设置形状填充的颜色,只有android:color一个属性
- android:color 填充的颜色
padding: 设置内容与形状边界的内间距,可分别设置左右上下的距离
- android:left 左内间距
- android:right 右内间距
- android:top 上内间距
- android:bottom 下内间距
gradient: 设置形状的渐变颜色,可以是线性渐变、辐射渐变、扫描性渐变
- android:type 渐变的类型
- linear 线性渐变,默认的渐变类型
- radial 放射渐变,设置该项时,android:gradientRadius也必须设置
- sweep 扫描性渐变
- android:startColor 渐变开始的颜色
- android:endColor 渐变结束的颜色
- android:centerColor 渐变中间的颜色
- android:angle 渐变的角度,线性渐变时才有效,必须是45的倍数,0表示从左到右,90表示从下到上
- android:centerX 渐变中心的相对X坐标,放射渐变时才有效,在0.0到1.0之间,默认为0.5,表示在正中间
- android:centerY 渐变中心的相对X坐标,放射渐变时才有效,在0.0到1.0之间,默认为0.5,表示在正中间
- android:gradientRadius 渐变的半径,只有渐变类型为radial时才使用
- android:useLevel 如果为true,则可在LevelListDrawable中使用
- android:type 渐变的类型
corners: 设置圆角,只适用于rectangle类型,可分别设置四个角不同半径的圆角,当设置的圆角半径很大时,比如200dp,就可变成弧形边了
- android:radius 圆角半径,会被下面每个特定的圆角属性重写
- android:topLeftRadius 左上角的半径
- android:topRightRadius 右上角的半径
- android:bottomLeftRadius 左下角的半径
- android:bottomRightRadius 右下角的半径
stroke: 设置描边,可描成实线或虚线。
- android:color 描边的颜色
- android:width 描边的宽度
- android:dashWidth 设置虚线时的横线长度
- android:dashGap 设置虚线时的横线之间的距离
----------------------------------shape的属性标签-----------------------------------------
android 自定义控件——(一)圆角按钮的更多相关文章
- android 圆角按钮和按钮颜色
1. android 设置圆角按钮后,按下按钮后,还能改变按钮的颜色 <?xml version="1.0" encoding="UTF-8"?> ...
- Android自定义控件实现带有清除按钮的EditText
首先声明我也是参考了别人的思路,只是稍微做了下修改,增加显示密码与隐藏密码,没有输入字符串时让EditText进行抖动,废话少说这里附上效果图 效果很赞有木有 那么怎么实现这种效果呢?那就跟着我一起来 ...
- Android自定义控件之自定义组合控件
前言: 前两篇介绍了自定义控件的基础原理Android自定义控件之基本原理(一).自定义属性Android自定义控件之自定义属性(二).今天重点介绍一下如何通过自定义组合控件来提高布局的复用,降低开发 ...
- Android 空心和实心按钮
Android 空心和实心按钮 做界面时 有时老要用到这种按钮 动画如下 实心的 <?xml version="1.0" encoding="utf-8" ...
- Android自定义控件 开源组件SlidingMenu的项目集成
在实际项目开发中,定制一个菜单,能让用户得到更好的用户体验,诚然菜单的样式各种各样,但是有一种菜单——滑动菜单,是被众多应用广泛使用的.关于这种滑动菜单的实现,我在前面的博文中也介绍了如何自定义去实现 ...
- Android自定义控件系列(一)—Button七十二变
转载请注明出处:http://www.cnblogs.com/landptf/p/6290791.html 忙了一段时间,终于有时间整理整理之前所用到的一些知识,分享给大家,希望给同学们有些帮助,同时 ...
- Android学习笔记-Button(按钮)
Button是TextView的子类,所以TextView上很多属性也可以应用到Button 上!我们实际开发中对于Button的,无非是对按钮的几个状态做相应的操作,比如:按钮按下的时候 用一种颜色 ...
- Android shape制作圆角、虚线、渐变
xml控件配置属性 android:background="@drawable/shape" 标签 corners ----------圆角 gradient ---------- ...
- Android自定义控件之自定义组合控件(三)
前言: 前两篇介绍了自定义控件的基础原理Android自定义控件之基本原理(一).自定义属性Android自定义控件之自定义属性(二).今天重点介绍一下如何通过自定义组合控件来提高布局的复用,降低开发 ...
随机推荐
- 微信小程序之用户数据解密(七)
[未经作者本人同意,请勿以任何形式转载] 经常看到有点的小伙伴在群里问小程序用户数据解密流程,所以打算写一篇关于小程序用户敏感数据解密教程: 加密过程微信服务器完成,解密过程在小程序和自身服务器完成, ...
- .Net程序在linux mono环境和WindowsServer上执行测试对比
最近研究了一下mono,想把windows上写的.Net程序移植到linux上跑.网上有资料说Linux上mono执行.Net程序效率比Windows高,本着实证的态度,只有实际验证过才有说服力. 写 ...
- 一步步搭建自己的博客 .NET版(2、评论功能)
前言 这次开发的博客主要功能或特点: 第一:可以兼容各终端,特别是手机端. 第二:到时会用到大量html5,炫啊. 第三:导入博客园的精华文章,并做分类.(不要封我) 第四:做 ...
- C++的性能C#的产能?! - .Net Native 系列五:.Net Native与反射
此系列系小九的学堂原创翻译,翻译自微软官方开发向导,一共分为六个主题.本文是第五个主题:.Net Native与反射. 向导文链接:<C++的性能C#的产能?! - .Net Native 系列 ...
- ABP教程-对Person信息进行操作
这一章的功能比较简单.下面开始 修改视图 对person的视图文件进行修改 <div class="row"> <div class="col-md-1 ...
- LeetCode-1TwoSum(C#)
# 题目 1. Two Sum Given an array of integers, return indices of the two numbers such that they add up ...
- 【翻译】MongoDB指南/引言
[原文地址]https://docs.mongodb.com/manual/ 引言 MongoDB是一种开源文档型数据库,它具有高性能,高可用性,自动扩展性 1.文档数据库 MongoDB用一个文档来 ...
- Javascript的“上下文”(context)
一:JavaScript中的“上下文“指的是什么 百科中这样定义: 上下文是从英文context翻译过来,指的是一种环境. 在软件工程中,上下文是一种属性的有序序列,它们为驻留在环境内的对象定义环境. ...
- 浅析JavaScript事件流——冒泡
一.什么是事件冒泡流 我们知道事件流指的是从页面中接受事件的顺序. 为了形象理解事件冒泡,可以想象三军主将诸葛亮,在帐内运筹帷幄,眼观六路耳听八方,这时候前方的战事情况就需要靠传令兵来传达,当第一位传 ...
- 使用ETag进行session的降级
回顾 在web后台开发中我们经常需要存储一些变量到session中进行暂存,最为特殊的就是"购物车",由于http的无状态特性,因此我们需要在客户端打上一个标记,唯一的标示客户端并 ...