Reputation: 1
I want to maintain the screen size in Layout
when the keyboard appears, my idea is obtain the next in both cases (with or without keyboard):
|-----------------| | image | | | |-----------------| | | | center lay | | | |-----------------| | | | image | |-----------------|
But in the center layout I have some EditText
and when the soft KeyBoard appear, the center layout reduce its height and is shorter, causing the first EditText
sticking to the picture above. I tried several forms, for example with a RelativeLayout
align the images at the top and bottom, but when the keyboard appears hide the center layout and causes a horrible effect.
This is my code by now,
<?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">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/login_iv_points_top"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_gravity="top"
android:src="@drawable/image" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<EditText
android:id="@+id/login_et_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/login_edit_margin_left"
android:layout_marginRight="@dimen/login_edit_margin_right"
android:ems="10"
android:hint="@string/login_et_email"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/login_et_pass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/login_edit_margin_left"
android:layout_marginRight="@dimen/login_edit_margin_right"
android:layout_marginTop="@dimen/login_edit_pass_margin_top"
android:ems="10"
android:hint="@string/login_et_pass"
android:inputType="textPassword" />
<Button
android:id="@+id/login_bt_login"
android:layout_width="match_parent"
android:layout_height="@dimen/login_button_height"
android:layout_marginLeft="@dimen/login_button_margin_left"
android:layout_marginRight="@dimen/login_button_margin_right"
android:layout_marginTop="@dimen/login_button_margin_top"
android:background="@drawable/bt_selectable_degraded_style"
android:text="@string/login_bt_access"
android:textColor="@color/bt_text_color" />
<TextView
android:id="@+id/login_tv_forgot_pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/login_forgot_margin_top"
android:linksClickable="true"
android:onClick="registerForgotClick"
android:text="@string/login_tv_forgot_pass"
android:textColorLink="@color/company_color" />
</LinearLayout>
<ImageView
android:id="@+id/login_iv_points_bottom"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="bottom"
android:src="@drawable/image" />
</LinearLayout>
</ScrollView>
Upvotes: 0
Views: 4929
Reputation: 2457
If you will remove windowSoftInputMode from manifest you will loss your scrolling so if you have a static image i mean from drawable resource than try this getWindow().setBackgroundDrawableResource(R.drawable.ic_launcher);
Upvotes: 0
Reputation: 41
Try to use this in activity inside manifest file:
android:configChanges="keyboardHidden|orientation"
android:windowSoftInputMode="adjustPan"
Upvotes: 1
Reputation: 1941
Maybe you can try to put android:windowSoftInputMode="adjustNothing"
on the activity node of your Android Manifest. The keyboard will then pop over the content.
Upvotes: 2