user1107888
user1107888

Reputation: 1525

Elements below Expandble listview in android

I am using an ExpandableListView in my android application.The problem I am facing is that if I have some elements such as a textview below the expandablelistview, it is hidden when a group is clicked and its children are displayed.This happends when I use LinearLayout.Following is my code:

<LinearLayout
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
 >
<ExpandableListView
    android:id="@android:id/list"
    style="@style/listStyle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:groupIndicator="@drawable/group_indicator"

    />
   <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="TextView below ExpandableListView"
/>
</LinearLayout>

If I replace LinearLayout with RelativeLayout, the reverse happens. The textview is not hidden but either the chidren of the open group or the lower groups in the list are hidden below the textview.How can I solve this probem?

Upvotes: 1

Views: 531

Answers (1)

Android Stack
Android Stack

Reputation: 4314

Add this line to code :

 android:layout_weight="1"

It will be as follow :

  <LinearLayout  
     android:orientation="vertical"
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent"    > 
 <ExpandableListView   
     android:id="@android:id/list"  
     style="@style/listStyle"    
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"
     android:layout_weight="1"
     android:groupIndicator="@drawable/group_indicator"          />
  <TextView   
     android:layout_width="fill_parent"
     android:layout_height="wrap_content" 
     android:text="TextView below ExpandableListView"   />
</LinearLayout>

Hope this help .

Upvotes: 1

Related Questions