android:duplicateParentState属性解释
android:duplicateParentState指的是当前控件是否跟随父控件的(点击、焦点等)状态
例:假设一Layout有两子View,对Layout进行监听点击事件;子ViewA一个设置duplicateParentState为true,子 View设置为false,当点击Layout后,子ViewA的点击态背景变色成功,子ViewB背景态变色无效,因为点击事件被Layout捕获。效 果如下图:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="44dp"
android:id="@+id/finger_memo"
android:background="@drawable/setting_bottom" >
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:duplicateParentState="false"
android:gravity="top"
android:id="@+id/txt_memo"
android:paddingTop="10.5dp"
android:paddingBottom="10.5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txt_finger_memo"
android:layout_alignParentTop="true"
android:includeFontPadding="false"
android:text="@string/info_troopintro"
android:layout_marginLeft="12dp"
android:minWidth="74dp"
android:textColor="@color/color_777777_white"
android:duplicateParentState="false"
android:textSize="15sp" />
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/open_arrow"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="12dp"
android:src="@drawable/arrow_right_gray_white" />
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/open_arrow"
android:layout_toRightOf="@id/txt_memo"
android:duplicateParentState="true"
android:paddingTop="10.5dp"
android:paddingLeft="10.5dp"
android:paddingBottom="10.5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txt_finger_memo_content"
android:layout_gravity="center_vertical|left"
android:includeFontPadding="false"
android:textColor="@color/color_333333_white"
android:text="@string/content"
android:duplicateParentState="true"
android:textSize="15sp"/>
</RelativeLayout>
</RelativeLayout>
<p style="margin-top: 0px; margin-bottom: 10px; padding-top: 0px; padding-bottom: 0px;">)xml中与像素有关的单位</p><div><ol style="margin: 5px 0px 5px 40px; padding: 0px;"><li>px(像素):屏幕上的点。 </li><li>in(英寸):长度单位。 </li><li>mm(毫米):长度单位。 </li><li>pt(磅):/72英寸。 </li><li>dp(与密度无关的像素):一种基于屏幕密度的抽象单位。在每英寸160点的显示器上,1dp = 1px。 在大于160点的显示器上可能增大。 </li><li>dip:与dp相同,多用于Google示例中。 </li><li>sp(与刻度无关的像素):与dp类似,但是可以根据用户的字体大小首选项进行缩放。 </li></ol></div><wbr>
)是否复制它的父布局的状态<p style="margin-top: 0px; margin-bottom: 10px; padding-top: 0px; padding-bottom: 0px;">在xml文件中添加如下属性:
android:duplicateParentState="true"</p><p style="margin-top: 0px; margin-bottom: 10px; padding-top: 0px; padding-bottom: 0px;">当这个属性设置为"true"时,这个控件将优先从它的直接父控件获得当前的图片状态(例如,focused, pressed等等)。
对应java代码中的方法:
isDuplicateParentStateEnabled()</p>
</wbr>
android:duplicateParentState属性解释的更多相关文章
- android:duplicateParentState属性使用场景
对于这个属性的使用也是在偶然的时候发现的,之前从未使用它,所以有必要阐述一下它的用法,什么场景会要用它这个属性,在我不知道之前这个属性之前,也同样能实现效果,但是当我知道它的存在之后,我肯定在某种场景 ...
- <Android>从窗口泄漏谈android:configChanges属性
今天有幸去哥们的大公司做了半天的暂时工,一个偶现的Bug折腾了他好久,好不easy今天抓到了异常Log日志.大致的意思就是android.view.windowleaked--窗口泄漏.我在网上查了资 ...
- 【Android开发经验】android:windowSoftInputMode属性具体解释
本文章来自CSDN博客:http://blog.csdn.net/zhaokaiqiang1992.转载请注明地址! 在前面的一篇文章中,简单的介绍了一下怎样实现软键盘不自己主动弹出,使用的方法是设置 ...
- android动画具体解释二 属性动画原理
property动画是一个强大的框架,它差点儿能使你动画不论什么东西. 你能够定义一个动画来改变对象的不论什么属性,不论其是否被绘制于屏幕之上. 一个属性动画在一定时间内多次改变一个属性(对象的一个字 ...
- Android 组件属性
属性名称 描述 android:background 设置背景色/背景图片.可以通过以下两种方法设置背景为透明:”@android:color/transparent”和”@null”.注意TextV ...
- view组件的duplicateParentState属性
今天做页面的时候遇到一个小问题,在点击的时候改变组件的图片来源,这个很简单大家都知道,用selector可以很快实现.但是现状有点特殊,是 LinearLayout 中包裹着一个 ImageView ...
- Android layout属性大全
第一类:属性值 true或者 false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 ...
- 【转】android布局属性详解
LinearLayout布局: 线性版面配置,在这个标签中,所有元件都是按由上到下的排队排成的.在这个界面中,我们应用了一个 LinearLayout的布局,它是垂直向下扩展的 ,所以创建的布局XML ...
- Android slidingmenu详细解释 滑动的优化
Android slidingmenu 详细解释 性能优化 转载请注明: http://blog.csdn.net/aaawqqq 简单介绍 SlidingMenu 是github 上Androi ...
随机推荐
- logstash ArgumentError: comparison of String with 5 failed
<pre name="code" class="html"><pre name="code" class="ht ...
- pidof,pgrep进程名查PID, /proc目录由pid查进程名
pidof,pgrep进程名查PID cat /proc/4990/status|grep "name",由pid查进程名
- C#中单问号,双问号的用法(转)
原文:http://hi.baidu.com/guodong828/blog/item/c78fc23f847314cb7d1e7193.html 单问号---用于给变量设初值的时候,给变量(int类 ...
- 无Root抓包:Packet Capture 1.2.3
无Root抓包:Packet Capture 1.2.3 http://www.coolapk.com/apk/app.greyshirts.sslcapture
- windows常用net use命令
net share :查看本地主机的共资源 nbtstat -A IP :得到远程主机的用户列表 net user c:/del 删除映射的C盘,其它盘类推 net user * /del 删除全部映 ...
- Linux查看系统状态及备份
1. 如何看当前Linux系统有几颗物理CPU和每颗CPU的核数?cat /proc/cpuinfo将CPU的总核数除以物理CPU的个数,得到每颗CPU的核数.2. 查看系统负载有两个常用的命令,是哪 ...
- Javascript基础引用类型之Object
虽然说ECMAScript也是一门对象语言,但是它和其他面向对象语言还是有区别的,它不具有类和接口等基本结构.所以在ECMAScript中一般说类指的是引用类型.创建Object实例的方式有两种: 第 ...
- Javascript进阶篇——(DOM—节点---获取浏览器窗口可视区域大小+获取网页尺寸)—笔记整理
浏览器窗口可视区域大小获得浏览器窗口的尺寸(浏览器的视口,不包括工具栏和滚动条)的方法:一.对于IE9+.Chrome.Firefox.Opera 以及 Safari: • window.innerH ...
- 实施双工通信框架:SignalR
SignalR:基于Asp.net平台构建,利用JavaScript或者Websockets,实现在客户端与服务端异步通信的框架. Html5新规范:WebSocket
- Windows命令行(DOS命令)教程-6 (转载)http://arch.pconline.com.cn//pcedu/rookie/basic/10111/15325_5.html
8. type [功能] 在屏幕上显示文本文件内容命令 [格式] type [C:][path]filename.ext [说明] type命令用来在屏幕上快速.简便地显示文本文件的内容,扩展名为TX ...