Android:duplicateparentstate attribute Interpretation

Source: Internet
Author: User

Android:duplicateparentstate refers to whether the current control follows the state of the parent control (click, Focus, and so on)

Example: Suppose a layout has two sub-views, the layout of the monitoring click event; Viewa a setting of Duplicateparentstate is true, child view is set to False, when you click Layout, Sub-Viewa of the click-State background color success, sub-VIEWB background state discoloration is invalid, because the Click event is captured by layout. Effects such as:

<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 ;">1) The pixel-related units in XML </p><div><ol style="margin:5px 0px 5px 40px; padding:0px;"&GT;&LT;LI&GT;PX (pixels): The point on the screen. </li><li>inch(inches): unit of length.  &LT;/LI&GT;&LT;LI&GT;MM (mm): unit of length. &LT;/LI&GT;&LT;LI&GT;PT (LB):1/72 inches. &LT;/LI&GT;&LT;LI&GT;DP (density-independent pixels): An abstract unit based on screen density. 1DP = 1px on a monitor 160 dots per inch.  May increase on a monitor larger than 160 points.  </li><li>dip: Same as DP, more for Google samples.  &LT;/LI&GT;&LT;LI&GT;SP (scale independent pixels): Similar to DP, but can be scaled based on the user's font size preference. </li></ol></div><wbr>2) Whether to copy the state of its parent layout <p style="margin-top:0px; margin-bottom:10px; padding-top:0px; padding-bottom:0px ;">Add the following attribute to the XML file: Android:duplicateparentstate="true"</p><p style="margin-top:0px; margin-bottom:10px; padding-top:0px; padding-bottom:0px ;"> When this property is set to"true", this control takes precedence from its immediate parent control to get the current picture state (for example, focused, pressed, and so on). Corresponding to the method in Java code: isduplicateparentstateenabled ()</p></wbr>

Android:duplicateparentstate attribute Interpretation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.