I have a pretty simple login page for an Android app containing the title, TextView username, TextView password, login button and image footer:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:src="@drawable/header" />
</LinearLayout>
<LinearLayout android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="90dip"
android:layout_alignParentBottom="true"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:src="@drawable/footer" />
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip"
android:layout_below="@+id/header"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:gravity="center"
android:padding="10dip"
android:textSize="25dp"
android:textStyle="bold"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="User Name"
android:textColor="#372c24" />
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_marginTop="5dip"
android:singleLine="true" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Password"
android:textColor="#372c24" />
<EditText
android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_marginTop="5dip"
android:password="true"
android:singleLine="true" />
<Button
android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Logon" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
I have two problems that I think of:
- When the keyboard is inserted and I scroll down, I see that the image footer is “hiding” behind the login button, instead of staying below it.
- The same thing happens when the screen is oriented horizontally.
What I tried:
- The activity setting
android:windowSoftInputMode="adjustPan", but I want to scroll down when the keyboard appears, or android:windowSoftInputMode="adjustResize"or any other parameter, if it is important. - Setting
marginBottomin the button.
.
.