通过android XML 创建图形,降低对美工的依赖
在开发中总会须要自己定义各种View的样式,假设总是依赖美工作图弄出须要的UI样式图片(比方:一个button要选中和默认两张图片),不但时间上会浪费、往往也会有适配问题。
尽管能够通过.9图来解决一些适配问题。依旧要花不少时间,毕竟美工通常不懂.9图的制作(得自己动手)。所以有时能够通过简单的创建android XML的方式制作须要的View的UI样式(不但快捷,更不会有适配问题)。
(带有点击、选中、默认三总状态)
>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected = "true"><!--
选中状态 -->
<shape android:shape="rectangle"><!--
图形形状 rectangle为矩形、oval为椭圆、line为线、ring为环形 -->
<corners android:radius="4dip"/><!--
四周圆角,也能够单独设置某一个角为圆角 如:设置topLeftRadius -->
<solid android:color="#33ffffff"/><!--
中心填充色 -->
<stroke android:width="2.0px" android:color="#ffffffff"/><!--
边框线宽度和颜色设置 -->
</shape>
</item>
<item android:state_pressed="true"><!--
点击状态 -->
<shape android:shape="rectangle">
<corners android:radius="4dip"/>
<solid android:color="#33ffffff"/>
<stroke android:width="2.0px" android:color="#ffffffff"/>
</shape>
</item>
<item><!--
默认状态 -->
<shape android:shape="rectangle">
<corners android:radius="4dip"/>
<solid android:color="#00ffffff"/>
<stroke android:width="2.0px" android:color="#ffffffff"/>
</shape>
</item>
</selector>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/start_use_btn_selector"
android:includeFontPadding="false"
android:paddingBottom="2dip"
android:paddingLeft="28dip"
android:paddingRight="28dip"
android:paddingTop="2dip"
android:text="立即体验"
android:textColor="#FFFFFFFF"
android:textSize="20sp" />
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGluc2VuNjE4/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

通过android XML 创建图形,降低对美工的依赖的更多相关文章
- Android xml 绘制图形
一般用shape定义的xml文件存放在drawable目录下,若项目没有该目录则新建一个,而不要将它放到drawable-hdpi等目录中. 使用shape可以自定义形状,可以定义下面四种类型的形状, ...
- Android:创建可穿戴应用 - 安装和依赖管理
安装可穿戴应用 在开发时,你能够像一般移动应用一样直接把应用安装到可穿戴设备中. 使用adb install或者 Android Studio上的Play button. 当你准备好要公布时,你须要把 ...
- Drawable实战解析:Android XML shape 标签使用详解(apk瘦身,减少内存好帮手)
Android XML shape 标签使用详解 一个android开发者肯定懂得使用 xml 定义一个 Drawable,比如定义一个 rect 或者 circle 作为一个 View 的背景. ...
- Android XML shape 标签使用详解(apk瘦身,减少内存好帮手)
Android XML shape 标签使用详解 一个android开发者肯定懂得使用 xml 定义一个 Drawable,比如定义一个 rect 或者 circle 作为一个 View 的背景. ...
- Android 数据库管理— — —创建数据库
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=" ...
- android XMl 解析神奇xstream 六: 把集合list 转化为 XML文档
前言:对xstream不理解的请看: android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 android XMl 解析神奇xs ...
- android XMl 解析神奇xstream 五: 把复杂对象转换成 xml ,并写入SD卡中的xml文件
前言:对xstream不理解的请看: android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 android XMl 解析神奇xs ...
- android 自己创建一个凝视模板
android 自己创建一个凝视模板 作为一名程序猿 不仅要有一个写代码的能力,养成一个良好的编写习惯也是非常重要的. 今天给大家具体介绍一下怎样创建凝视模板,给每一个类和方法都自己手动去凝视信息也 ...
- Android Studio创建JAR/AAR库
[时间:2017-09] [状态:Open] [关键词:Android,Android Studio,gradle,jar,aar,library] 0 引言 最近在工作中遇到了升级Android S ...
随机推荐
- 1433端口无法连接(sql server 数据库无法访问问题)解决思路
登录远程SQL服务器一 看ping 服务器IP能否ping通. 这个实际上是看和远程sql server 2000服务器的物理连接是否存在.如果不行,请检查网络,查看配置,当然得确保远程sql ser ...
- leetcode_655. Print Binary Tree
https://leetcode.com/problems/print-binary-tree/ 打印整棵二叉树 class Solution { public: int getTreeHeight( ...
- jquery 获取日期 date 对象、 判断闰年
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Flask框架 之模版
一.过滤器 safe:禁用转义: <p>{{ '<em>hello</em>' | safe }}</p> capitalize:把变量值的首字母转成大 ...
- python pandas读写excel
import pandas as pd import numpy as np df = pd.read_csv("result.csv") # csv # df = pd.read ...
- Core Animation教程
http://dev.wo.com.cn/bbs/viewthread.jsp?tid=141767&page=1 http://blog.csdn.net/lvxiangan/article ...
- react-native Socket Event 在控制台的输出
在XCode中运行react-native 的时候,避免不了的要查看日志信息 ,但是react-native中的Socket的日志简直是太多了,往往是刚看到自己想要看到的信息的时候,瞬间就被最新的日志 ...
- BZOJ 2039 人员雇佣 二元关系 最小割
题面太长了,请各位自行品尝—>人员雇佣 分析: 借用题解的描述: a.选择每个人有一个代价Ai b.如果有两个人同时选择就可以获得收益Ei,j c.如果一个人选择另一个不选会产生代价Ei,j 这 ...
- mac apache 配置
mac系统自带apache这无疑给广大的开发朋友提供了便利,接下来是针对其中的一些说明 一.自带apache相关命令 1. sudo apachectl start 启动服务,需要权限,就是你计算机的 ...
- LeetCode(54)Spiral Matrix
题目 Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral ...