简体   繁体   中英

Layout below expandable view is not visible?

<LinearLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:id="@+id/linearLayoutUser"
  >

<!-- TODO: Update blank fragment layout -->

<ExpandableListView
    android:id="@+id/expandableListView"

    android:layout_width="match_parent"
    android:layout_alignParentTop="true"
    android:groupIndicator="@null"
    android:layout_gravity="left|top"
    android:layout_weight="1"



    />

//only above code is visible //Below this code is not visible //below is details information inside scrollview

    <ScrollView

        android:layout_width="match_parent"


        android:layout_gravity="center"
        android:layout_weight="1"
        >
  </scrollView>

</LinearLayout>

Set proper android:layout_weight and android:layout_height value .

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:id="@+id/linearLayoutUser">

          <ExpandableListView
            android:id="@+id/expandableListView"
            android:layout_height="0dp"
            android:layout_width="match_parent"
            android:layout_alignParentTop="true"
            android:groupIndicator="@null"
            android:layout_gravity="left|top"
            android:layout_weight="1"/>    

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:fillViewport="true">
       // your work
   </ScrollView>
</LinearLayout>

Change your xml to:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayoutUser"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ExpandableListView
        android:id="@+id/expandableListView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_gravity="left|top"
        android:layout_weight="1"
        android:groupIndicator="@null" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true">

        <!--Scroll view with only one direct child-->

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <!--Do your work here-->

        </LinearLayout>
    </ScrollView>

</LinearLayout>

There are two properties which is used for weight. 1) layout_weight
2) weightsum

In a container/parent (a lineaLayout) You should set a layout_weightsum which is the total amount of weights you are using inside this layout.

Here,you have linearlayout with two items, and both items have to have the same height.

You will set a sum of 2 and for each layout a weight of 1 for each child layout.

Hope it will help!

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayoutUser"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="2">

    <ExpandableListView
        android:id="@+id/expandableListView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_gravity="left|top"
        android:layout_weight="1"
        android:groupIndicator="@null" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:layout_weight="1">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <!--Add your other part which you want to show in ScrollView-->

        </LinearLayout>
    </ScrollView>
</LinearLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM