Generally, I use a selector to select pictures or colors to render the normal and the pressed background for View.

And use a Shape to draw a fixed background with border, round, gradient and other UI effect for View.

What if you wanna use them both for one View?

Make a Shape as one item of the Selector.

Selector selects background from Shape list.

Below is a sample.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version=”1.0″ encoding=”UTF-8″?>
<selector xmlns:android=”http://schemas.android.com/apk/res/android”>
<item android:state_pressed=”true”>
<shape android:shape=”rectangle”>
<solid android:color=”@color/background_pressed” />
<stroke android:width=”@dimen/gap_2″ android:color=”@color/linecolor” />
<padding android:bottom=”@dimen/gap_2″ android:left=”@dimen/gap_2″
android:right=”@dimen/gap_2″ android:top=”@dimen/gap_2″ />
</shape>
</item> <item>
<shape android:shape=”rectangle”>
<solid android:color=”@color/background_normal” />
<stroke android:width=”@dimen/gap_2″ android:color=”@color/linecolor” />
<padding android:bottom=”@dimen/gap_2″ android:left=”@dimen/gap_2″
android:right=”@dimen/gap_2″ android:top=”@dimen/gap_2″ />
</shape>
</item>
</selector>

Shape + Selector: Make a Shape as one item of the Selector的更多相关文章

  1. [Java] Design Pattern:Code Shape - manage your code shape

    [Java] Design Pattern:Code Shape - manage your code shape Code Shape Design Pattern Here I will intr ...

  2. android selector中使用shape

    <shape> <!-- 实心 -->     <solid android:color="#ff9d77"/> <!-- 渐变 --&g ...

  3. [UWP]不怎么实用的Shape指南:自定义Shape

    1. 前言 这篇文章介绍了继承并自定义Shape的方法,不过,恐怕,事实上,100个xaml的程序员99个都不会用到.写出来是因为反正都学了,当作写个笔记. 通过这篇文章,你可以学到如下知识点: 自定 ...

  4. Computer Vision_2_Active Shape Models:Active Shape Models-Their Training and Application——1995

    此为计算机视觉部分,主要侧重在底层特征提取,视频分析,跟踪,目标检测和识别方面等方面. 1. Active Appearance Models 活动表观模型和活动轮廓模型基本思想来源 Snake,现在 ...

  5. InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [2048,38] rhs shape= [2048,2]

    做tensorflow object detection 中,清空下checkpoint就可以啦

  6. SNIPER-MXNet中出现ValueError: could not broadcast input array from shape (XXX,5) into shape (100,5)

    这是关于标签数量的问题,搜索"100," ,其中与读标签框有关,或者与标签匹配有关的,全部改到大于“图片中最多有的标签数量”即可.

  7. Objective C SEl 和@selector是怎么工作的||How do SEL and @selector work in iphone sdk?

    SEL is a type that represents a selector in Objective-C. The @selector() keyword returns a SEL that ...

  8. 在JavaScript中实现yield,实用简洁实现方式。

    原题还是老赵的: http://blog.zhaojie.me/2010/06/code-for-fun-iterator-generator-yield-in-javascript.html 原以为 ...

  9. Android UI一些技巧

    (1)去掉EditText的背景颜色  android:background="@null" (2)ListView 修改某行的值,因为一些功能逻辑,需要修改ListView某行的 ...

随机推荐

  1. Java 并发编程之volatile关键字解析

    摘录 1. 计算机在执行程序时,每条指令都是在CPU中执行的,而执行指令过程中,势必涉及到数据的读取和写入.由于程序运行过程中的临时数据是存放在主存(物理内存)当中的,这时就存在一个问题,由于CPU执 ...

  2. Linux下开发常用 模拟 Http get和post请求

    1.get请求 curl "http://www.baidu.com"      如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地 curl -i "htt ...

  3. ECSHOP MYSQL 公用类库中的autoExecute方法

    include/cls_mysql.php 正常操作 例如: $sql = “UPDATE ecs_user SET user = ‘buxuan’ WHERE user_id = ″; $db-&g ...

  4. 取出return array() 数组内容

    d.php文件 return array( "0" => 内容一, "1" => 内容二, "2" => 内容三, &qu ...

  5. yum配置文件详解

    yum是什么: Yellow dog Updater, Modified主要功能是更方便的添加/删除/更新RPM包,自动解决包的倚赖性问题,它能便于管理大量系统的更新问题. yum特点:可以同时配置多 ...

  6. sn 密钥注册

    ::打开开发人员命令提示符输入一下内容与证书密码sn -i CanChou.snk.pfx VS_KEY_4B89A33EE2B53C07

  7. Database Schema Reader

    数据架构与INSERT脚本生成 https://dbschemareader.codeplex.com/wikipage?title=Writing%20Data&referringTitle ...

  8. 固定IP 正常访问谷歌

    如题 地址栏直接输入 http://173.194.1.150/ 正常使用 ~标记一下~

  9. SCWS分词扩展在UNIX/LINUX下的安装方法

    <?php/** * 中文分词处理方法 *+--------------------------------- * @param stirng  $string 要处理的字符串 * @param ...

  10. 微信C# SDK

    微信C# SDK # 模块功能 DLL 1 基础库 Senparc.Weixin.dll 2 微信公众号 / 微信支付 / JSSDK / 摇周边 / 等等 Senparc.Weixin.MP.dll ...