2014-09-09 3 views
-1

내 프로젝트는 또한 MvvmCross와 Xamarin을 사용하지만이 문제는 모든 view-layout/axml과 관련되어 있기 때문에 응답하지 않을 것이라고 생각합니다.안드로이드 클릭 가능 레이아웃 위의 빈보기

연락처 목록을 요약하는 GridView가 있습니다. 이 격자보기를 클릭하면 다른 화면으로 이동하여이 목록에 연락처를 더 추가하여 공간을 확보하고 싶습니다. GridView의 OnClick 이벤트를 구독하면 항목 클릭 이벤트에 가입해야한다는 예외가 발생하므로 GridView (및 해당 빈 이미지보기)를 둘러싸는 클릭 가능한 상대 레이아웃을 사용하여이 작업을 수행했습니다.

... 
<RelativeLayout 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent" 
      android:id="@+id/addContactsRelativeLayout" 
      android:clickable="true"> 
      <ImageView 
       android:id="@+id/empty" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:src="@drawable/ic_add" /> 
      <Mvx.MvxGridView 
       android:id="@+id/addContactsGridView" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       local:MvxBind="ItemsSource Contacts" 
       local:MvxItemTemplate="@layout/contact_summary_item" 
       android:numColumns="auto_fit" 
       android:stretchMode="columnWidth" 
       android:columnWidth="55dip" 
       android:gravity="center" /> 
     </RelativeLayout> 
... 

GridView가 비어 있고 빈 ImageView가 표시되면 제대로 작동합니다. 그러나 GridView에 항목이 있으면 RelativeLayout이 더 이상 존재하지 않고 GridView를 클릭하면 GridView의 항목을 강조 표시 할 수 있습니다. 즉, 사용자는 대화 상대 목록을 편집하기 위해 화면으로 이동하지 않습니다.

나는 여러 가지 다른 구성과 속성을 비슷한 질문에서 시도했지만, 빈보기를 추가하면 문제가 발생한다고 생각합니다. 어떤 도움이라도 대단히 감사하겠습니다.

답변

0

좋아, 훨씬 더 놀고 난 후에 해결책을 찾았습니다.

본질적으로 그것은 z- 색인에서 더 높은 또 다른 상대적인 레이아웃을 추가하기 때문에 주변의 상대적 레이아웃 내에서 '실제'내용보다 위에 있습니다.

... 
<RelativeLayout 
      android:layout_height="wrap_content" 
      android:layout_width="match_parent"> 
      <ImageView 
       android:id="@+id/empty" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:src="@drawable/ic_add" /> 
      <Mvx.MvxGridView 
       android:id="@+id/addContactsGridView" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       local:MvxBind="ItemsSource Contacts" 
       local:MvxItemTemplate="@layout/contact_summary_item" 
       android:numColumns="auto_fit" 
       android:stretchMode="columnWidth" 
       android:columnWidth="55dip" 
       android:gravity="center" 
       android:focusable="false"/> 
      <RelativeLayout 
       android:layout_height="match_parent" 
       android:layout_width="match_parent" 
       android:clickable="true" 
       android:id="@+id/addContactsRelativeLayout"/> 
... 

그런 다음 하단의 상대 레이아웃을 듣기 위해 모든 클릭 수신기를 이동하십시오.