Reputation: 1013
I have the following code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_box">
<ScrollView
android:id="@+id/main_scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
[... center stuff]
</ScrollView>
<RelativeLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/auth_non_auth_bottom"
android:layout_below="@+id/main_scroll">
[... buttons and stuff]
</RelativeLayou>
</RelativeLayout>
And inside the Scrollview there is an EditText. Since the EditText can change its height, the Scrollview can run over the RelativeLayout pushing it outside the view!
However, if I put the RelativeLayout with the parentBottom, it goes above the keyboard hiding the edittext while typing, so the user can't write... and if I put the RelativeLayout inside the scrollview.. it won't be at the bottom of the View.
Any idea to accomplish the goal of having the RelativeLayout at the bottom BUT not hiding the EditText (that would be in the center area)? Thanks!
Upvotes: 0
Views: 101
Reputation: 1013
I did it! In this way:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_box">
<ScrollView
android:id="@+id/main_scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="50dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
[...]
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/auth_non_auth_bottom"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
I set a marginBottom to the ScrollView in order to see the editText field :)
Upvotes: 0
Reputation: 1595
I would rather go for something like following:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background_box">
<ScrollView
android:id="@+id/main_scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:lines="3"
android:inputType="textMultiLine"
android:id="@+id/description"
android:clickable="true"/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/auth_non_auth_bottom"
android:layout_below="@+id/main_scroll">
<!--[... buttons and stuff]-->
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Upvotes: 1