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. python编程之字符串转处理

    比如255的16进制是FF. 转换成整型就是  int("FF",16)   console上输出就是255   int("FFFF",16)就是65535 如 ...

  2. POJ 3280 Cheapest Palindrome 简单DP

    观察题目我们可以知道,实际上对于一个字母,你在串中删除或者添加本质上一样的,因为既然你添加是为了让其对称,说明有一个孤立的字母没有配对的,也就可以删掉,也能满足对称. 故两种操作看成一种,只需要保留花 ...

  3. 转:ASP.Net MVC:校验、AJAX与过滤器

    原文地址:http://blog.jobbole.com/85005/ 一.校验 — 表单不是你想提想提就能提 1.1 DataAnnotations(数据注解) 位于 System.Componen ...

  4. cf493B Vasya and Wrestling

    B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. PyQt4--QPushButton阵列

    # -*- coding: utf-8 -*- from PyQt4.QtCore import * from PyQt4.QtGui import * import sys import funct ...

  6. python高级编程:有用的设计模式3

    # -*- coding: utf-8 -*-__author__ = 'Administrator'#python高级编程:有用的设计模式#访问者:有助于将算法从数据结构中分离出来"&qu ...

  7. Codeforces Round #260 (Div. 2)A. Laptops

    A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  8. Eclipse下绿色安装插件Aptana、Swing

    本文主要针对Ecplise下绿色安装插件,写本篇博客也是因为笔者在Ecplise下安装Aptana时不断安装出现错误,所以写下自己安装成功以及之前出错的原因,也搜集了许多资料在此一并总结一下吧! Ec ...

  9. 调用具体webservice方法时时报错误:请求因 HTTP 状态 503 失败: Service Temporarily Unavailable

    添加web引用会在相应项目的app.cofig文件中产生如下代码: <sectionGroup name="applicationSettings" type="S ...

  10. #JavaScript对象与继承

    JavaScript对象与继承 JavaScript是我在C语言之后接触的第二门编程语言,大一暑假的时候在图书馆找了一本中国人写的JavaScript程序设计来看.那个时候在编程方面几乎还是小白,再加 ...