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属性解释的更多相关文章

  1. android:duplicateParentState属性使用场景

    对于这个属性的使用也是在偶然的时候发现的,之前从未使用它,所以有必要阐述一下它的用法,什么场景会要用它这个属性,在我不知道之前这个属性之前,也同样能实现效果,但是当我知道它的存在之后,我肯定在某种场景 ...

  2. &lt;Android&gt;从窗口泄漏谈android:configChanges属性

    今天有幸去哥们的大公司做了半天的暂时工,一个偶现的Bug折腾了他好久,好不easy今天抓到了异常Log日志.大致的意思就是android.view.windowleaked--窗口泄漏.我在网上查了资 ...

  3. 【Android开发经验】android:windowSoftInputMode属性具体解释

    本文章来自CSDN博客:http://blog.csdn.net/zhaokaiqiang1992.转载请注明地址! 在前面的一篇文章中,简单的介绍了一下怎样实现软键盘不自己主动弹出,使用的方法是设置 ...

  4. android动画具体解释二 属性动画原理

    property动画是一个强大的框架,它差点儿能使你动画不论什么东西. 你能够定义一个动画来改变对象的不论什么属性,不论其是否被绘制于屏幕之上. 一个属性动画在一定时间内多次改变一个属性(对象的一个字 ...

  5. Android 组件属性

    属性名称 描述 android:background 设置背景色/背景图片.可以通过以下两种方法设置背景为透明:”@android:color/transparent”和”@null”.注意TextV ...

  6. view组件的duplicateParentState属性

    今天做页面的时候遇到一个小问题,在点击的时候改变组件的图片来源,这个很简单大家都知道,用selector可以很快实现.但是现状有点特殊,是 LinearLayout 中包裹着一个 ImageView ...

  7. Android layout属性大全

    第一类:属性值 true或者 false  android:layout_centerHrizontal 水平居中      android:layout_centerVertical 垂直居中   ...

  8. 【转】android布局属性详解

    LinearLayout布局: 线性版面配置,在这个标签中,所有元件都是按由上到下的排队排成的.在这个界面中,我们应用了一个 LinearLayout的布局,它是垂直向下扩展的 ,所以创建的布局XML ...

  9. Android slidingmenu详细解释 滑动的优化

    Android slidingmenu 详细解释 性能优化 转载请注明:   http://blog.csdn.net/aaawqqq 简单介绍 SlidingMenu 是github 上Androi ...

随机推荐

  1. NSIS脚本调用C语言写的插件

    其实NSIS的官网已经提供了很多别人开发的插件了,今天需要用到GetVersion这个插件,这是不维护的插件了,不推荐用,但是由于现实中的问题,导致我不得不用这个插件. 所以就下载下来了. 下载下来之 ...

  2. jtree(选择框)

    jtree一般的用法是: 1. 展示电脑中文件的层次结构,如图所示. 具体的代码: package jtree; import java.io.File; import javax.swing.JTr ...

  3. FreeBSD简单配置SSH并用root远程登陆方法

    FreeBSD简单配置SSH并用root远程登陆方法 前言:最近下载了FreeBSD,在虚拟机上安装,第一步先要开启SSH服务,用终端putty软件可以实现在windows系统进行远程管理, 初级 = ...

  4. spring 配置文件XSD地址

    这边部署不能访问外网,所以sping配置文件里的XSD地址要改一下象  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd ...

  5. 关于static静态

    静态属性与方法可以在不实例化类的情况下调用,直接使用类名::方法名的方式进行调用.静态属性不允许对象使用->操作符调用. class Car { private static $speed = ...

  6. PYCHARM配置文件如何导入

    请到此下载,如下: http://share.weiyun.com/c00040649e85c4ab1dbc47a0fe9a0a7a 或者:http://files.cnblogs.com/files ...

  7. C/C++基础概念

    1.类占用的内存大小: 1)在不同位数的操作系统下,各种数据类型所占用的内存大小:32位和64位操作系统 http://blog.csdn.net/b_zhang/article/details/68 ...

  8. DIV 与 Table 嵌套

    当然可以了.对于DIV定义表示一块可显示 HTML 的区域. Specifies a container that renders HTML. 注释此元素在 Internet Explorer 3.0 ...

  9. getInitParameter()

      getInitParameter()方法是在GenericServlet接口中新定义的一个方法,用来调用初始化在web.xml中存放的参量.在web.xml配置文件中一个servlet中参量的初始 ...

  10. neural style论文解读

    相关的代码都在Github上,请参见我的Github,https://github.com/lijingpeng/deep-learning-notes 敬请多多关注哈~~~ 概述 在艺术领域,艺术家 ...