Reputation: 2660
Without Scrollview, Button is on the bottom on the screen, which is the desired result. But as soon as I add the Scrollview, the button is not at the bottom of the screen anymore.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/create_account_view">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/scrollview_wrapper"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="0dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:lines="1"
android:gravity="center"
android:textSize="16sp"/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Upvotes: 0
Views: 86
Reputation: 45
just add the scrolling view behavior to the scroll view
app:layout_behavior = "@string/appbar_scrolling_view_behavior"
and add the code to button xml file
android:layout_alignParentBottom = "true"
android:layout_centerHorizontal = "true"
Upvotes: 0
Reputation: 20258
Add another attribute to ScrollView
:
android:fillViewport="true"
This way ScrollView
height will respect child's android:layout_height="match_parent"
attribute
Upvotes: 1
Reputation: 591
The problem is in the scroll view, just add the following attribute to your scroll view.
android:fillViewport="true"
Upvotes: 0
Reputation: 415
try this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/create_account_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button1">
</ScrollView>
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="0dp"
android:gravity="center"
android:lines="1"
android:textSize="16sp" />
</RelativeLayout>
Upvotes: 0