1

I would like my button to be at the bottom of my layout but it doesn't seem to be working. Somehow it's stuck at the middle of my screen and it won't go down... code below. My main LinearLayout seems to have a match_parent height though...

<ScrimInsetsScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="@dimen/navdrawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:id="@+id/navdrawer"
    android:background="@color/navdrawer_background"
    android:fitsSystemWindows="true"
    app:insetForeground="#4000">

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

        <FrameLayout
            android:id="@+id/chosen_account_view"
            android:layout_width="match_parent"
            android:layout_height="@dimen/navdrawer_chosen_account_height"
            android:layout_alignParentTop="true">
            <!--android:foreground="?photoItemForeground"-->
            <!-->-->

            <ImageView android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/ic_foodie_nav_image"
                android:tint="@color/session_photo_scrim"
                android:id="@+id/profile_cover_image"
                />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingLeft="@dimen/keyline_1"
                android:paddingRight="@dimen/keyline_1"
                android:paddingTop="@dimen/keyline_1"
                android:id="@+id/chosen_account_content_view"
                android:onClick="showProfile">

                <com.pkmmte.view.CircularImageView
                    android:id="@+id/profile_image"
                    android:layout_width="@dimen/navdrawer_profile_image_size"
                    android:layout_height="@dimen/navdrawer_profile_image_size"
                    android:src="@drawable/ic_action_person"
                    android:scaleType="centerCrop"
                    android:layout_marginTop="16dp"
                    />

                <ImageView
                    android:id="@+id/expand_account_box_indicator"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:visibility="gone"
                    android:layout_marginLeft="16dp"
                    android:paddingBottom="16dp"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentBottom="true"
                    android:scaleType="center"
                    android:src="@drawable/ic_drawer_accounts_expand" />

                <TextView
                    android:id="@+id/profile_email_text"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@id/profile_image"
                    android:layout_toLeftOf="@id/expand_account_box_indicator"
                    android:layout_alignParentBottom="true"
                    android:paddingBottom="16dp"
                    android:textSize="@dimen/text_size_medium"
                    android:textColor="@color/body_text_2_inverse"
                    android:maxLines="1"
                    android:singleLine="true"
                    android:ellipsize="end"/>

                <TextView
                    android:id="@+id/profile_name_text"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_above="@id/profile_email_text"
                    android:layout_alignLeft="@id/profile_image"
                    android:layout_toLeftOf="@id/expand_account_box_indicator"
                    android:textSize="@dimen/text_size_large"
                    android:textColor="@color/body_text_1_inverse"
                    android:maxLines="1"
                    android:singleLine="true"
                    android:ellipsize="end"
                    android:textStyle="bold"/>

            </RelativeLayout>

        </FrameLayout>


        <FrameLayout android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >
            <!-- Account items -->
            <LinearLayout
                android:id="@+id/account_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:orientation="vertical"
                android:visibility="invisible" />

            <LinearLayout
                android:id="@+id/navdrawer_items_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp"
                android:orientation="vertical"
                />
        </FrameLayout>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:background="@color/red_500"
            android:layout_gravity="bottom"
            android:gravity="bottom"
            />

    </LinearLayout>

</ScrimInsetsScrollView>
Stephane Maarek
  • 5,202
  • 9
  • 46
  • 87

1 Answers1

1

The solution is in that post LinearLayout not expanding inside a ScrollView

Found the solution myself in the end. The problem was not with the LinearLayout, but with the ScrollView (seems weird, considering the fact that the ScrollView was expanding, while the LinearLayout wasn't).

The solution was to use android:fillViewport="true" on the ScrollView.

Just use it on the Scrimset

Community
  • 1
  • 1
Stephane Maarek
  • 5,202
  • 9
  • 46
  • 87