2011-03-09 7 views
12

xml 코드에 중첩 된 일련의 선형 레이아웃이 있습니다. 부모의 첫 번째 자식 (선형 레이아웃)이 포커스를 원한다. 내가 사실에 초점을 맞춘다면 그렇게한다. 또한이 레이아웃의 하위에 초점을 맞추기를 원합니다 (상태 목록을 호출하기 위해). 그러나 초점이 맞추어 져 있다고하더라도 초점이 맞지 않습니다. 어떤 아이디어가 이것을 어떻게? 감사합니다선형 레이아웃에서 부모에서 자식으로 포커스 전달

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:weightSum="1" 
     android:layout_height="wrap_content" 
     android:background="@drawable/resultpage_statelist" 
     android:focusable="true" 
     android:clickable="true"> 
     <TextView 
      android:text="TextView" 
      android:layout_height="wrap_content" 
      android:paddingTop="5dip" 
      android:paddingBottom="5dip" 
      android:paddingLeft="10dip" 
      android:layout_width="fill_parent" 
      android:layout_weight="0.8" 
      android:id="@+id/tag_row_text" 
      android:textSize="16dip" 
      android:padding="10dip" 
      android:textColor="@drawable/resultpage_grey_text_statelist" 
      android:background="#00000000" 
      android:focusable="true"> 
     </TextView> 
     <ImageView 
      android:layout_height="wrap_content" 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_gravity="right|center_vertical" 
      android:src="@drawable/arrow_statelist" 
      android:layout_marginRight="10dip" 
      android:background="#00000000" 
      android:focusable="true"> 
     </ImageView> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:background="#6E6E6E" 
     android:layout_height="1dip"> 
    </LinearLayout> 
</LinearLayout> 

답변

30

은 XML 속성 '안드로이드 : duplicateParentState'사용 설정을 true로 아이 뷰에 부모의 그리기 상태를 상속받을 수 있습니다. 여기

자세한 내용 : http://developer.android.com/reference/android/view/View.html#attr_android:duplicateParentState

+0

D' 오! 왜 내가 그 부동산을 찾지 않았 니?! 고마워, 내 머리를 쓰고 있었어! – steemcb

+0

WOOOOOOOOOOOOOOW – hasan83

+0

@ hasan83 - lol .... 당신은 명쾌함의 순간을 가졌습니까? – dell116

관련 문제