Search code examples
android-layoutandroid-linearlayout

LinearLayout - Positioning Views


I have this layout.

<RelativeLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/numbers_root"
        android:orientation="vertical"
        android:gravity="top"
        >
        <ListView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/numbersList"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="116dp"
    android:clipToPadding="false"
    tools:layout_height="100dp"
    ></ListView>
        <ExpandableListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/subcategory_expandable"
            >
        </ExpandableListView>

    </LinearLayout>
</RelativeLayout> 

But the problem is that the ExpandableListView is always centered on screen despite gravity="top" in the parent Layout. What I want is to have it start exactly where the ListView ends. Any idea what might be causing this? Should I use a scrollview instead of linearlayout?

Here is a screenshot to clarify: enter image description here

I want the expandable listview to appear below the listview.


Solution

  • I think the issue is that you're paddingBottom="116dp" on the ListView is pushing the ExpandableListView down.