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. angularjs笔记(三)

    AngularJS API 7.其他一些常用指令,布尔类型的指令也可以用表达式 (1).数组索引$index <!DOCTYPE html> <html> <head&g ...

  2. ubuntu rhythmbox乱码解决方法

    因为安装的是双系统,所以音乐文件在win的盘下面,所以采用的方法是 1. 首先,需要有软件包mid3iconv.如果你的系统中没有安装它,可以通过如下代码自动安装:sudo apt-get insta ...

  3. Session共享的解决方案

    http://www.cnblogs.com/xinhaijulan/archive/2010/08/21/1805116.html Session共享的解决方案 1.客户端SessionID值唯一: ...

  4. Entity Framework - Using Transactions or SaveChanges(false) and AcceptAllChanges()?

    LINK With the Entity Framework most of the time SaveChanges() is sufficient. This creates a transact ...

  5. JQ nextALL() 实现遍历

    在我们的 手机端 常常需要 应用到 hide 和 show 的方法 来节省页面的版块 那么我们需要更多的是 需要 show 一个 <li>  hide 剩下的 <li> 那么 ...

  6. 请问如何查看mysql 的端口号?

    mysql> show variables like 'port'; +---------------+-------+ | Variable_name | Value | +--------- ...

  7. 浅谈javascript函数节流

    浅谈javascript函数节流 什么是函数节流? 函数节流简单的来说就是不想让该函数在很短的时间内连续被调用,比如我们最常见的是窗口缩放的时候,经常会执行一些其他的操作函数,比如发一个ajax请求等 ...

  8. 如何判断retina,如何判断设备的比例

    http://www.189works.com/article-95647-1.html 说起iPhone 4带来的革新,retina display绝对是最吸引眼球的一项,以至于我现在看电脑的显示屏 ...

  9. Mysql CPU占用90%

    今天网站打开卡,查了下发现Mysql CPU占用到90%! 1.通过putty工具连接mysql putty工具十分的强大,它可以让我们直接访问MySQL.当然,要实现这一步肯定要做点什么.MySQL ...

  10. ML_R Kmeans

    Kmeans作为机器学习中入门级算法,涉及到计算距离算法的选择,聚类中心个数的选择.下面就简单介绍一下在R语言中是怎么解决这两个问题的. 参考Unsupervised Learning with R ...