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. Android学习笔记——MixLayout

    该工程的功能是实现LinearLayout+TableLayout 以下代码是MainActivity.java中的代码 package com.example.mixlayout; import a ...

  2. HTTP 传输内容的压缩

    一.HTTP压缩和内容编码的区别 HTTP压缩,在HTTP协议中,其实是内容编码的一种. 在http协议中,可以对内容(也就是body部分)进行编码, 可以采用gzip这样的编码. 从而达到压缩的目的 ...

  3. C++中引用与指针的区别(详细介绍)

    C++中引用与指针的区别(详细介绍) C++中的引用与指针的区别   指向不同类型的指针的区别在于指针类型可以知道编译器解释某个特定地址(指针指向的地址)中的内存内容及大小,而void*指针则只表示一 ...

  4. Unity3D Multi-Compile Shader

    http://www.martinpalko.com/muli-compile-unity/ http://forum.unity3d.com/threads/tutorial-shade-more- ...

  5. live555库中的testRTSPClient实例

    1.testRTSPClient简介 testRTSPClient是个简单的客户端实例,这个实例对rtsp数据交互作了详细的描述,其中涉及到rtsp会话的两个概念Source和Sink. Source ...

  6. 微信jssdk录音功能开发记录

    原文地址:http://www.cnblogs.com/liujunyang/p/4962423.html

  7. codeforces #270 ABCD

    Codeforces Round #270 A - Design Tutorial: Learn from Math 题意:给出n,求出两个合数x和y使x+y=n. 题解:暴力筛合数,然后暴力找 // ...

  8. IOS表情存入MYSQL数据库失败

    从 MySQL 5.5.3 开始,MySQL 支持一种 utf8mb4 的字符集,这个字符集能够支持 4 字节的 UTF8 编码的字符. utf8mb4 字符集能够完美地向下兼容 utf8 字符串.在 ...

  9. JDBC:从数据库中取数据的一个bug

    先看错误信息: java.sql.SQLException: Before start of result set at com.mysql.jdbc.SQLError.createSQLExcept ...

  10. 解决英文或数字在HTMl网页中不自动换行。

    对于网页设计的新手而言,在接触一段时间的HTML/CSS后,一定会遇到这样的问题:对于已经定义了宽度的容器(如DIV,TD,段落等)如果里面出现了较长的英文或数字,则内容不能自动换行然后会将框架撑出设 ...