2014-02-12 5 views
0
I가을 갖도록하는 linear layout with horizontal orientation에서 다음 효과 을 동일 선상에 2 개 확장형의 ListView를 만들

2 확장형 목록보기 가로 폭 : match_parent

기대 동작 (리스트가 확장에 따라) 프롬프트를 클릭하면

********************************************** 
* v list1       | v list2 * 
********************************************** 
* Item1 List1 or List2      * 
* Item2 List1 or List2      * 
* Item3 List1 or List2      * 
* Item4 List1 or List2      * 
* Item5 List1 or List2      * 
* Item6 List1 or List2      * 
********************************************** 

항목은 list1 또는 list2의 항목이 될 수 있습니다. 그래서 너비가 match parent 일 필요가 있습니다.

내가 (지금 무엇을 가지고 내가 첫 번째 부분은 부모 폭의 3/4이있는 확대 LIST1 클릭하고리스트 2 클릭 할 때 난 단지 두 번째 부분이있을 때 :

을 현재 동작 : 목록 1에

************************************************* 
* v list1      | v list2  * 
************************************************* 
* Item1 List1     *    * 
* Item2 List1     *    * 
* Item3 List1     *    * 
* Item4 List1     *    * 
* Item5 List1     *    * 
* Item6 List1     *    * 
************************************************* 

현재 동작을 클릭하면 다음과 같은 경우리스트 2에 클릭

************************************************* 
* v list1      | v list2  * 
************************************************* 
*        * Item1 List2 * 
*        * Item2 List2 * 
*        * Item3 List2 * 
*        * Item4 List2 * 
*        * Item5 List2 * 
*        * Item6 List2 * 
************************************************* 

목록 항목에는 부모 너비가 없습니다. 나는이 같은 짓을 한

:

<LinearLayout 
     android:id="@+id/adm_ll_media" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:baselineAligned="false" 
     android:orientation="horizontal" > 

     <ExpandableListView 
      android:id="@+id/adm_list_media" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_gravity="left" /> 

     <ExpandableListView 
      android:id="@+id/adm_add_media" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="3" 
      android:layout_gravity="right" /> 
    </LinearLayout> 

그러나 논리적으로 그 중 하나는 선형 레이아웃 폭의 3/4과 다른 1/4한다. 그래서 내가하고 싶은 것은 부모의 너비의 1/4과 3/4 만하라는 것입니다.

이것에 대해 알고 계십니까?

+0

글쎄, 그것들이 쪼개지는 이유는'android : layout_weight'입니다. 프롬프트에 해당 가중치를 지정하려면 해당 가중치를 프롬프트에 할당하십시오. – BigT

+0

글쎄 ...이 일을하는 방법에 대한 아이디어가 .... ?? ... – Copernic

+0

그래서 1/4와 3/4이되는 뷰를 원하십니까? – BigT

답변

0

android:layout_weight 속성을 사용하는 경우, 당신은 0dpandroid:layout_width 속성을 설정해야한다 : 프롬프트가 당신이 라벨을 의미하는 경우

<LinearLayout 
    android:id="@+id/adm_ll_media" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:baselineAligned="false" 
    android:orientation="horizontal" 
    android:weightSum="4" 
> 

    <ExpandableListView 
     android:id="@+id/adm_list_media" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_gravity="left" /> 

    <ExpandableListView 
     android:id="@+id/adm_add_media" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="3" 
     android:layout_gravity="right" /> 
</LinearLayout> 
+0

감사합니다. 그러나 너비에 'Odp'를 사용하는 이벤트 인 경우 layout_weight의 동작은 동일하게 유지되며 프롬프트뿐만 아니라 소비 된 요소에도 적용됩니다. – Copernic

+0

두 개의 스크린 샷을 제공해 주시겠습니까? 현재와 ​​예상되는 행동? – ninetwozero

+0

업데이트 된 질문을 확인하십시오. – Copernic

0

는 (V 목록 1) 및 확장 요소에 의해 당신이 나는 믿습니다 목록을 의미 두 목록 모두에 별도의 TextView를 추가해야 Prompt처럼 작동합니다. 그들에게 가중치 (1/4 및 3/4 비율)를 할당 한 다음 목록의 내용을 감싸는 폭을 지정하십시오.

<LinearLayout 
    android:id="@+id/adm_ll_media" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:baselineAligned="false" 
    android:orientation="horizontal" > 

    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 
     <TextView 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:layout_height="wrap_content" 
     android:text="v list1"> 

     <TextView 
     android:layout_width="0dp" 
     android:layout_weight="3" 
     android:layout_height="wrap_content" 
     android:text="v list2"> 
    </LinearLayout>   


    Your ListViews here with a layout_width of match_parent, within an another LinearLayout with layout_width = match_parent 
</LinearLayout> 
+0

새 이미지대로 편집.이것을 시도해보십시오. 또한 목록 내에서 하나의 레이블 (v list1로 헤더) 만 있으면 TextViews를 사용하여 머리글을 얻을 수 있으므로 ListView를 사용하면됩니다. –