Reputation: 1036
Have googled a lot but couldnt find a satisfying solution. The below screenshot depicts the issue I am facing.
Edittext hides behind titlebar when soft keyboard is visible. I have put
android:gravity="center_vertical"
property in the main layout. If i remove this property then the layout works fine.But the design requirement needs the form to be in center.I have tried everything.Tried using scrollview and putting this into manifest
android:windowSoftInputMode="stateVisible|adjustResize"
Have also tried "adjustPan" and it does works.But in this case the entire form is not pushed up.the edittext 'MobileNo' and the button stays hidden behind soft keyboard.
Layout xml code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="324dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#39CCCCCC"
android:orientation="vertical"
android:isScrollContainer="true"
android:padding="5dp"
>
<EditText android:id="@+id/edit_name"
android:layout_width="match_parent"
android:layout_height="@dimen/edittext_dimen"
android:hint="@string/register_name"
android:textColor="@color/black"
android:textSize="20sp"
android:background="@drawable/rounded_edittext_bg"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="20dp"
android:padding="5dp"
android:inputType="textPersonName"/>
<EditText android:id="@+id/edit_email"
android:layout_width="match_parent"
android:layout_height="@dimen/edittext_dimen"
android:hint="@string/register_emailid"
android:textColor="@color/black"
android:textSize="20sp"
android:background="@drawable/rounded_edittext_bg"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:padding="5dp"
android:inputType="textEmailAddress" />
<EditText android:id="@+id/edit_password"
android:layout_width="match_parent"
android:layout_height="@dimen/edittext_dimen"
android:hint="@string/register_pass_hint"
android:textColor="@color/black"
android:textSize="20sp"
android:background="@drawable/rounded_edittext_bg"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:padding="5dp"
android:inputType="textPassword" />
<EditText android:id="@+id/edit_confpassword"
android:layout_width="match_parent"
android:layout_height="@dimen/edittext_dimen"
android:hint="@string/register_confpass"
android:textColor="@color/black"
android:textSize="20sp"
android:background="@drawable/rounded_edittext_bg"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:padding="5dp"
android:inputType="textPassword" />
<EditText android:id="@+id/edit_mobile"
android:layout_width="match_parent"
android:layout_height="@dimen/edittext_dimen"
android:hint="@string/register_mobile"
android:textColor="@color/black"
android:textSize="20sp"
android:background="@drawable/rounded_edittext_bg"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:padding="5dp"
android:maxLength="11"
android:inputType="phone"/>
<Button android:id="@+id/signup_btn"
android:layout_width="match_parent"
android:layout_height="@dimen/edittext_dimen"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_gravity="center_horizontal"
android:text="@string/register_signup"
android:textSize="20sp"
android:background="#3F799F"
android:textColor="@color/white"/>
</LinearLayout>
</LinearLayout>
Is there any solution for this? Any workaround that could help me achieve my goal? please reply with your views and suggestions.
If you are not able to understand my doubt.Please feel free to ask. Thank you in advance.
Upvotes: 2
Views: 2712
Reputation: 9131
I explain Your mistakes. You have given liner layout hight as 324dp .so when Keyboard open Linear Layout require that much space in screen so it goes up and not visible Your first edittext.
Use relative layout instead.
Wait for some moment I give you modified XML with change. till time check your xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="5dp" >
<LinearLayout
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#39CCCCCC"
android:isScrollContainer="true"
android:orientation="vertical"
android:padding="5dp" >
<EditText
android:id="@+id/edit_name"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="20dp"
android:hint="Name"
android:inputType="textPersonName"
android:padding="5dp"
android:textColor="#000"
android:textSize="20sp" />
<EditText
android:id="@+id/edit_email"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:hint="Email"
android:inputType="textEmailAddress"
android:padding="5dp"
android:textColor="#000"
android:textSize="20sp" />
<EditText
android:id="@+id/edit_password"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:hint="password"
android:inputType="textPassword"
android:padding="5dp"
android:textColor="#000"
android:textSize="20sp" />
<EditText
android:id="@+id/edit_confpassword"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:hint="Confirm password"
android:inputType="textPassword"
android:padding="5dp"
android:textColor="#000"
android:textSize="20sp" />
<EditText
android:id="@+id/edit_mobile"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:hint="register"
android:inputType="phone"
android:maxLength="11"
android:padding="5dp"
android:textColor="#000"
android:textSize="20sp" />
<Button
android:id="@+id/signup_btn"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#3F799F"
android:text="signup"
android:textColor="#fff"
android:textSize="20sp" />
</LinearLayout>
</RelativeLayout>
Activity Tag in manifest write this android:windowSoftInputMode="adjustResize|adjustPan"
I change your dimention, size, color also String resourch
Upvotes: 3
Reputation: 6162
add adjustPan
in manifest under activity
tag
android:windowSoftInputMode="adjustResize|adjustPan"
Upvotes: 1