0

I was having trouble in layouts. I have ExpandableListView & ListView . when I view that fragment ExpandableListView will overlap above ListView(images)

I Wanted ExpandableListView should appear after ListView.

ScreenShot:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    <android.support.v7.widget.CardView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <ListView
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/climages" />
        <ExpandableListView
            android:id="@+id/catExpandableListview"
            android:minWidth="25px"
            android:minHeight="25px"
            android:groupIndicator="@android:color/transparent"
            android:layout_width="fill_parent"
            android:indicatorRight="45sp"
            android:layout_height="wrap_content" />
        <ProgressBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/homeProgress"
            android:layout_gravity="center" />
    </android.support.v7.widget.CardView>
</FrameLayout>

Edited: Changed RelativeLayout to FrameLayout

Rami
  • 7,879
  • 12
  • 36
  • 66
Raj
  • 1,083
  • 8
  • 22

2 Answers2

0

Try using the following layout instead of the above.I modified it and it gives the desired result

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
        <ListView
            android:minWidth="25px"
            android:minHeight="25px"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/climages" />
        <ExpandableListView
            android:id="@+id/catExpandableListview"
            android:minWidth="25px"
            android:minHeight="25px"
            android:groupIndicator="@android:color/transparent"
            android:layout_width="fill_parent"
            android:indicatorRight="45sp"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/homeProgress"
        android:layout_gravity="center" />

</android.support.v7.widget.CardView>
Anirudh Sharma
  • 7,968
  • 13
  • 40
  • 42
  • ExpandableListView is not visible. Seems its back of listview – Raj Apr 28 '15 at 06:33
  • @Raj i guess yoy expandable list view is visible.The problem might be that beacuse you are using two listviews in a single layout and your first view contains data large enough to hide the expandable list view.The expandable list view is just below your list view.But you are unable to scroll it as your whole layout is not scrollable. – Anirudh Sharma Apr 28 '15 at 06:56
  • @Raj try hiding your list view and then see if expandable list view is there or not – Anirudh Sharma Apr 28 '15 at 06:56
  • @Raj ok you can use weight to give equal height to your both list view as mentioned by Rami – Anirudh Sharma Apr 28 '15 at 06:58
  • @Raj or you can put your whole layout in a scroll view.Ex:-http://stackoverflow.com/questions/17693578/android-how-to-display-2-listviews-in-one-activity-one-after-the-other – Anirudh Sharma Apr 28 '15 at 06:59
0

Try to use android:layout_weight :

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <android.support.v7.widget.CardView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">

                <LinearLayout 
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical">
                    <ListView
                        android:minWidth="25px"
                        android:minHeight="25px"
                        android:layout_width="fill_parent"
                        android:layout_height="0dp"
                        android:id="@+id/climages"
                        android:layout_weight="0.5" />
                    <ExpandableListView
                        android:layout_width="fill_parent"
                        android:layout_height="0dp" 
                        android:id="@+id/catExpandableListview"
                        android:minWidth="25px"
                        android:minHeight="25px"
                        android:groupIndicator="@android:color/transparent"
                        android:indicatorRight="45sp"
                        android:layout_weight="0.5"/>
              </LinearLayout>

              <ProgressBar
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/homeProgress"
                  android:layout_gravity="center" />
          </RelativeLayout>
     </android.support.v7.widget.CardView>
</FrameLayout>
Rami
  • 7,879
  • 12
  • 36
  • 66
  • I don't want to give them equal height. i just want ExpandableListView below listview – Raj Apr 28 '15 at 07:03
  • I don't think it's possible to do it like that, you'll always have the overlap problem. Maybe as workaround you can put your two lists inside a ScrollView and update their height every remove/add of an item. Notice that the use of two scrollable views inside each other is not recommended – Rami Apr 28 '15 at 07:13