android:duplicateParentState屬性解釋

來源:互聯網
上載者:User

標籤:

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;">1)xml中與像素有關的單位</p><div><ol style="margin: 5px 0px 5px 40px; padding: 0px;"><li>px(像素):螢幕上的點。  </li><li>in(英寸):長度單位。  </li><li>mm(毫米):長度單位。  </li><li>pt(磅):1/72英寸。  </li><li>dp(與密度無關的像素):一種基於螢幕密度的抽象單位。在每英寸160點的顯示器上,1dp = 1px。 在大於160點的顯示器上可能增大。  </li><li>dip:與dp相同,多用於Google樣本中。  </li><li>sp(與刻度無關的像素):與dp類似,但是可以根據使用者的字型大小喜好設定進行縮放。  </li></ol></div><wbr>2)是否複製它的父布局的狀態<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屬性解釋

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.