2016-11-11 4 views
0

Ich versuche, ein Buch Inhalte Selektor mit ExpandableListView zu implementieren, aber ich finde, dass LinearLayout scheint innerhalb der ELV anders als in einer Aktivität funktioniert.LinearLayout funktioniert in ExpandableListView

Um zu zeigen, was ich versuche, hier zu tun ist, wo ich so weit bin:

Screen Capture

enter image description here

Hinweis, wenn der Text hüllt in der nächsten Zeile, die Textview füllt der verfügbare Platz und richtet die vertikale Linie (und Button in der groupView) nach rechts (Abschnitt 1.1 und 3), aber wenn der Text nicht umschließt, nimmt der TextView nur so viel Platz wie nötig.

Hier ist das Layout der untergeordneten Ansicht, die Gruppenansicht ist ähnlich, aber mit einer Schaltfläche.

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@android:color/white" > 

     <View android:layout_width="3dp" android:layout_height="match_parent" android:background="#000000" /> 
     <View android:layout_width="10dp" android:layout_height="match_parent" /> 

     <TextView 
      android:id="@+id/sectionNumber" 
      android:layout_width="65sp" 
      android:layout_height="wrap_content" 
      android:textSize="18sp" /> 

     <TextView 
      android:id="@+id/sectionTitle" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:textSize="18sp" /> 

     <View android:layout_width="6dp" android:layout_height="match_parent" /> 
     <View android:layout_width="3dp" android:layout_height="match_parent" android:background="#000000" /> 

    </LinearLayout> 

Wenn ich dies außerhalb einer ExpandableListView versuchte, funktioniert es wie vorgesehen. Was vermisse ich?

Antwort

0

Das Problem war, an anderer Stelle im Fragment xml Layout:

<ExpandableListView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:id="@+id/expandableListView" /> 

layout_width gesetzt wurde "wrap_content" und hätte sein sollen "match_parent"

Verwandte Themen