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数据结构——有序链表

    //================================================= // File Name : SortedList_demo //--------------- ...

  2. SQL 使用小记

    1. case语句 示例 select id, name, case user_role then "管理员" then "未注册用户" then " ...

  3. HTTP协议发展脉络

    1 发展脉络 1.1 1991 HTTP/0.9 建立TCP连接.客户端发送请求(只有GET命令).服务端返回请求(只能返回html格式字符串)后就关闭TCP连接 1.2 1996.5 HTTP/1. ...

  4. 第3章 jQuery的DOM操作

    一.  DOM 分为DOM核心,HTML-DOM和CSS-DOM 1.DOM核心 不专属与javascript. 获取对象:document.getElementsByTagName('div') 获 ...

  5. C++ 纯虚函数接口,标准 C 导出 DLL 函数的用法

    CMakeLists.txt project(virtual) # 创建工程 virtual add_library(virtual SHARED virtual.cpp) # 创建动态连接库 lib ...

  6. VS编译器从DLL导出模板类

    DLL与模板 http://msdn.microsoft.com/en-us/library/twa2aw10.aspx http://www.codesynthesis.com/~boris/blo ...

  7. 扩展服务 修改新增Service的默认主题

    问题描述:想要在F:\PHPnow-1.5.6\htdocs\yt\Yourphp\Tpl\      目录下新增一个Service\Default(A)   和Service\new(B) 两个主题 ...

  8. iOS监听键盘事件

    #pragma mark - view life cycle - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter def ...

  9. GPRS/3G

    像GPRS/3G模块之类的应用,需要连接,登陆,初始化等步骤完成后才能传输数据,而这些步骤又比较耗时. 所以用 状态机 + 超时 的机制来实现比较合理. 如下代码片段来描述数据透传 : 状态机 + 超 ...

  10. thinkphp-许愿墙-3

    用jquery写异步传递的时候, 首先要判断表单中的输入是否为空: 如果有多个输入项, 应该, 分别的, 一步一步的来判断是否为空, 而不是用 and / or来复合判断! 同时如果为空, 应该将它设 ...