How to allow of contents behind the soft keyboard in android? - android

I have a scrollview that has android:fillViewport="true" so that it fills the screen when there is no keyboard. I want to add functionality so that the scrollview doesn't change when a keyboard pops up, but rather allows you to scroll the contents up from BEHIND the keyboard. Is this possible? I don't want the keyboard to pop up and everything gets squished together. Does anyone have a solution to this?

Setting height and width of scroll view to "match_parent" is the trick here.
Check below layout, it will help you.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scroll_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="38dp" >
<LinearLayout
android:id="#+id/relative_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="13dp"
android:paddingRight="8dp" >
<EditText
android:id="#+id/et_fullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:maxLength="30"
android:maxWidth="208dp"
android:paddingLeft="5dp"
android:singleLine="true"
android:textSize="13sp" />
<EditText
android:id="#+id/et_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLength="30"
android:maxWidth="208dp"
android:paddingLeft="5dp"
android:textSize="13sp" />
<EditText
android:id="#+id/et_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:digits="1234567890"
android:imeOptions="actionNext"
android:inputType="phone"
android:maxLength="12"
android:paddingLeft="5dp"
android:singleLine="true"
android:textSize="13sp" />
<EditText
android:id="#+id/et_fax"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="1234567890"
android:imeOptions="actionDone"
android:inputType="phone"
android:maxLength="12"
android:paddingLeft="5dp"
android:singleLine="true"
android:textSize="13sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:text="Botttom Text" />
</LinearLayout>
</ScrollView>
</LinearLayout>

Related

Bottom view is pushed up when keypad appears

The question is already asked here. But don't have satisfactory answer, so I am asking again.
I have a scrollable user registration form, and a fixed SignUp button at the bottom of the screen. And i need to show SignUp button at bottom only i.e. It shouldn't be scrollable. I am using RelativeLayout as root container.
My View Hierarchy is:
In case of android:windowSoftInputMode="adjustNothing"
When i tap in any of my EditText then the soft keyboard appears but scrollview is not completely scrollable. Space equivalent to keyboard is gone behind the keyboard. Which i want to make scrollable.
In case of android:windowSoftInputMode="adjustPan"
It works a bit better but not exactly the way i want it. It pushes my whole screen upward including toolbar which is not desired.
In case of android:windowSoftInputMode="adjustResize"
It pushes my button upward which is not required at all.
So, please suggest me a solution which i can use to fulfil my requirement.
Here is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
tools:context=".activities.CreateAccountActivity">
<include
android:id="#+id/toolbar"
layout="#layout/app_toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar"
android:fillViewport="true"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"><!--android:paddingBottom="#dimen/activity_vertical_margin"-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/ll_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/et_first_name"
style="#style/create_account_edittext"
android:hint="#string/first_name" />
<EditText
android:id="#+id/et_last_name"
style="#style/create_account_edittext"
android:hint="#string/last_name" />
<EditText
android:id="#+id/et_dob"
style="#style/create_account_edittext"
android:hint="#string/date_of_birth" />
<EditText
android:id="#+id/et_email"
style="#style/create_account_edittext"
android:hint="#string/email"
android:inputType="textEmailAddress" />
<EditText
android:id="#+id/et_password"
style="#style/create_account_edittext"
android:hint="#string/password"
android:inputType="textPassword" />
<EditText
android:id="#+id/et_confirm_password"
style="#style/create_account_edittext"
android:hint="#string/confirm_password"
android:inputType="textPassword" />
<LinearLayout
android:id="#+id/ll_terms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/separator_margin"
android:background="#color/et_create_account_bg"
android:orientation="horizontal"
android:padding="10dp">
<CheckBox
android:id="#+id/cb_terms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="#style/BrandedCheckbox" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="#string/accept_terms"
android:textColor="#color/white"
app:font="#string/font_helvetica_normal" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_subscription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/et_create_account_bg"
android:orientation="horizontal"
android:padding="10dp">
<CheckBox
android:id="#+id/cb_subscription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="#style/BrandedCheckbox" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:gravity="center_vertical"
android:text="#string/subscription_details"
android:textColor="#color/white"
app:font="#string/font_helvetica_normal" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/btn_create_account"
style="#style/buttonStyle"
android:layout_alignParentBottom="true"
android:text="#string/create_account" />
</RelativeLayout>
</ScrollView>
And my manifest is:
<activity
android:name=".activities.CreateAccountActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar" />
Wrap your layout in a scroll view, since scroll view can have only one child, it would be best for you to wrap your Relative layout in it.
<ScrollView>
<RelativeLayout>
...
</RelativeLayout>
</ScrollView>
Just Don't Use
android:windowSoftInputMode
So that by default it will do nothing to adjust when soft keyboard shows...
So don't use any of them...
Code Exemple
Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".ScrollView"
tools:showIn="#layout/activity_scroll_view">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Your Name..."/>
<EditText
android:id="#+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Father's Name.."/>
<EditText
android:id="#+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Mothers's Name.."/>
<EditText
android:id="#+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Email Address.."/>
<EditText
android:id="#+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Mobile No.."/>
<EditText
android:id="#+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Present Address.."/>
<EditText
android:id="#+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Parmanent Address.."/>
<EditText
android:id="#+id/editText8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Company Name.."/>
<EditText
android:id="#+id/editText9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<Button
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SignUp"/>
</LinearLayout>
</ScrollView>
Code in AndroidMaifest.xml for the activity
<activity
android:name=".ScrollView"
android:label="#string/title_activity_scroll_view"
android:theme="#style/AppTheme.NoActionBar">
</activity>

Android Custom Keyboard not resizing the window Issue

Hi i am following this link for implementing CustomKeyboard. Everything was perfect except if there are number of EditTexts in my layout. The window is not resizing when the keyboard appears, say if i am trying to enter data to EditTexts which are placed on bottom gets covered by the keyboard. The solutions like adjust resize and adjust pan with the manifest are not working in this case, also i tried with putting ScrollView in layout, but not getting any solution. Please see my layout given below.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="#+id/edittext0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext0"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/txt"
android:inputType="text" />
<EditText
android:id="#+id/edittext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext1"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/txt"
android:inputType="text" />
<EditText
android:id="#+id/edittext3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext2"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext3"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext5"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext6"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext7"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<!-- NOTE No need to develop a system service for keyboard, there is a standard View for that (well, not completely standard, its in a funny package 'android.inputmethodservice'. -->
<!-- NOTE The graphical layout does not know the package ('java.lang.NoClassDefFoundError: Could not initialize class android.inputmethodservice.KeyboardView') so the keyboard is not shown. -->
<!-- <android.inputmethodservice.KeyboardView
android:id="#+id/keyboardview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone"
android:background="#drawable/normal"/>
-->
<nl.fampennings.keyboard.CustomKeyboardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/keyboardview"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone"
android:keyBackground="#drawable/samplekeybackground"/>
Please help me with a solution. Thank you.
OK I got the solution. Please find the modified layout code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/edittext0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext0"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/txt"
android:inputType="text" />
<EditText
android:id="#+id/edittext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext1"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/txt"
android:inputType="text" />
<EditText
android:id="#+id/edittext3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext2"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext3"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext5"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext6"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext7"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
</LinearLayout>
</ScrollView>
<nl.fampennings.keyboard.CustomKeyboardView
android:id="#+id/keyboardview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:keyBackground="#drawable/samplekeybackground"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
Add a linearLayout as the child of main parent layout; Add a scroll View to that layout with weight 1 and add another layout to the scrollView as the container for child items like EditTexts and all. The keyboard view should be added in the same layout as the scrollView contains. I hope the solution will be helpful for someone.

Android: Ensuring EditText boxes fit horizontally across screen?

I am trying to allign 3 EditText boxes across the screen horizontally in my activity so that the user is able to enter data.
Currently the code that I am implementing doesnt allow the 3 boxes to fit on the screen. Only 1 box and half of the other are visible
How can I adjust my current code so that all 3 Edittext boxes are visible to the user?
Note: The button and textView at the bottom of the layout are also currently not visible, eventhough they should be under the 3 horizontally alligned Edittext boxes.
Current XML Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/tvSearchDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Enter Date to search..."
android:textSize="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText
android:id="#+id/etEnterSpecificyear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="" >
</EditText>
<TextView
android:layout_width="3dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<EditText
android:id="#+id/etEnterSpecificMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="" >
</EditText>
<TextView
android:layout_width="3dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<EditText
android:id="#+id/etEnterSpecificDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="" >
</EditText>
</LinearLayout>
<Button
android:id="#+id/btnSearchDate"
android:layout_width="85dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="Submit"
/>
<TextView
android:id="#+id/tvSearchResultsDate"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:maxLines="30"
android:minLines="5"
android:scrollbars="vertical"
android:text=" Results..."
android:textSize="15dp" />
</LinearLayout>
For each of your edittext make this:
<EditText
android:id="#+id/etEnterSpecificyear"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:hint="" >
</EditText>
And delete the TextView's that are in between the EditText's
Your issue is that you are using android:ems="10" in EditText properties. This one makes the minimum width of the EditText to be exact ten "M" characters. If this is your requirement I would suggest to use android:orientation="vertical" in the parent LinearLayout. So your final layout will look like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/tvSearchDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Enter Date to search..."
android:textSize="15dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/etEnterSpecificyear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="">
</EditText>
<EditText
android:id="#+id/etEnterSpecificMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="">
</EditText>
<EditText
android:id="#+id/etEnterSpecificDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="">
</EditText>
</LinearLayout>
<Button
android:id="#+id/btnSearchDate"
android:layout_width="85dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="Submit"
/>
<TextView
android:id="#+id/tvSearchResultsDate"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:maxLines="30"
android:minLines="5"
android:scrollbars="vertical"
android:text=" Results..."
android:textSize="15dp"/>
</LinearLayout>

making Multiple EditText's scroll inside scrollview

I am trying to make the edittext's scroll in case the view doesn't them all. The user should be able to scroll the edittexts when keyboard is on or off.
I have tried multiple combinations of linearLayout and ScrollView but it doesn't seem to be working.
Can someone please check what is wrong with it?
<?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="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<TextView
android:id="#+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginTop="50dp"
android:text="Details"
android:textColor="#EB8024"
android:textSize="30sp" />
<EditText
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:background="#drawable/theme_textfield_activated_holo_light"
android:ems="10"
android:hint="URI"
android:inputType="text" />
<EditText
android:id="#+id/ip_addr"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#drawable/theme_textfield_activated_holo_light"
android:ems="10"
android:hint="IP Address"
android:inputType="text" />
<EditText
android:id="#+id/port"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#drawable/theme_textfield_activated_holo_light"
android:ems="10"
android:hint="Port"
android:inputType="text" />
<EditText
android:id="#+id/app_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#drawable/theme_textfield_activated_holo_light"
android:ems="10"
android:hint="Application Name"
android:inputType="text" />
<EditText
android:id="#+id/string"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#drawable/theme_textfield_activated_holo_light"
android:ems="10"
android:hint="Nick Names"
android:inputType="text" />
<Button
android:id="#+id/submit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginTop="20dp"
android:background="#drawable/theme_btn_default_disabled_focused_holo_light"
android:onClick="onClickNext"
android:text="Next"
android:textColor="#EB8024"
android:textSize="30sp" />
</LinearLayout>
</ScrollView>
Make your ScrollView fill the viewport and match parent's height instead of wrapping content.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">

Android keyboard overlap edittext when gravity set to "center"

I just want to know if you have already encounter this issue in edittext when you set the gravity to "center" the keyboard overlap the edittext. Hope you could help me fix this problem.
I added my code below.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/img_splash"
android:gravity="bottom"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="#+id/edit_username"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginBottom="13dp"
android:background="#drawable/img_textfield"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:hint="Username"
android:imeOptions="actionNext"
android:maxLines="1"
android:singleLine="true"
android:textSize="18sp" />
<EditText
android:id="#+id/edit_password"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginBottom="28dp"
android:background="#drawable/img_textfield"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:hint="Password"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:textSize="18sp" />
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/button_login"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginBottom="75dp"
android:background="#drawable/btn_login"
android:onClick="onClicked"
android:text="Login"
android:textColor="#color/white_pure"
android:textSize="18sp" />
</LinearLayout>
Try using
android:windowSoftInputMode="adjustResize|stateHidden" in manifest
Or put your view inside a scrollview
Source

Categories

Resources