making Multiple EditText's scroll inside scrollview - android

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">

Related

background is scrolling it should be constant?

I have designed the login layout as follows
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/login_bg">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:id="#+id/login_fields_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">
<ImageView
android:id="#+id/loginLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="30dp"
android:src="#drawable/logo" />
<EditText
android:id="#+id/userNameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:background="#drawable/textfield"
android:drawableLeft="#drawable/username"
android:drawablePadding="10dip"
android:hint="#string/hint_username"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLength="50"
android:padding="10dp"
android:singleLine="true"
android:textColor="#color/login_textcolor"
android:textCursorDrawable="#null" />
<EditText
android:id="#+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/textfield"
android:drawableLeft="#drawable/password"
android:drawablePadding="10dip"
android:hint="#string/hint_password"
android:imeOptions="actionNext"
android:inputType="textPassword"
android:padding="10dp"
android:singleLine="true"
android:textColor="#color/login_textcolor"
android:textCursorDrawable="#null" />
<LinearLayout
android:id="#+id/loginOptionsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="2">
<CheckBox
android:id="#+id/rememberMeCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="#null"
android:checked="false"
android:drawableEnd="#drawable/bg_checkbox"
android:gravity="center_vertical"
android:paddingRight="40dp"
android:text="#string/text_rememberme"
android:textColor="#color/login_textcolor"
android:textSize="14sp" />
<Button
android:id="#+id/forgotPasswordButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#null"
android:gravity="right|center_vertical"
android:singleLine="true"
android:text="#string/text_forgotpassword"
android:textColor="#color/login_textcolor"
android:textSize="14sp" />
</LinearLayout>
<Button
android:id="#+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="#drawable/button_bg"
android:text="#string/text_login"
android:textColor="#android:color/white"
android:textSize="20dp"
android:textStyle="bold" />`
</LinearLayout>
</ScrollView>
</RelativeLayout>
when the i touched on the edittext the background is moving up it need to be constant as it is outside the scrollview.How to solve this issue.
i have referred the following
Background Image Placement
as in this they need in the bottom corner i need it as background.but anyway with curiosity i tried it but still it is scrolling the background
I tried it and it works. Remove the background from xml layout
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE|WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
getWindow().setBackgroundDrawableResource(R.drawable.login_bg) ;
Use the following in your activity
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

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>

Failed to get Scrolling in device S3 using Android?

Here is my xml code i want to apply scrolling in View but no scroll appears in my device screen.Here is the XML Layout.Can someone please suggest me possible solutions to overcome on this situation.....
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/home_bg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/askfatwa_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/askfatwa_top_bar" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/askfatwa_header"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="#+id/name_askscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/name"
android:textColor="#android:color/white"
android:textSize="20sp" />
<EditText
android:id="#+id/askscreen_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:paddingLeft="5dp"
android:maxLines="1"
android:inputType="text"
android:background="#drawable/textfield" >
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="#+id/email_askscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Email"
android:textColor="#android:color/white"
android:textSize="20sp" />
<EditText
android:id="#+id/askscreen_email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:maxLines="1"
android:inputType="textEmailAddress"
android:background="#drawable/textfield"
android:paddingLeft="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="#+id/address_askscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Address"
android:textColor="#android:color/white"
android:textSize="20sp" />
<EditText
android:id="#+id/askscreen_address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:paddingLeft="5dp"
android:inputType="textMultiLine"
android:background="#drawable/textfield" />
</LinearLayout>
<!-- <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="#+id/contact_askscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Contact"
android:textColor="#android:color/white"
android:textSize="20sp" />
<EditText
android:id="#+id/askscreen_contact"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:paddingLeft="5dp"
android:background="#drawable/textfield" />
</LinearLayout> -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="#+id/subject_askscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Subject"
android:textColor="#android:color/white"
android:textSize="20sp" />
<!-- <EditText
android:id="#+id/askscreen_subject"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:paddingLeft="5dp" /> -->
<Spinner
android:id="#+id/askscreen_subject"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:paddingLeft="5dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<!-- <TextView
android:id="#+id/body_askscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Type Your Question"
android:textColor="#android:color/white"
android:textSize="20sp" /> -->
<EditText
android:id="#+id/askscreen_question"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:background="#drawable/textfield"
android:hint="Type Your Question"
android:minLines="1"
android:inputType="textMultiLine"
android:minHeight="8dp"
android:minWidth="10dp"
android:lines="15"
android:paddingLeft="5dp" />
</LinearLayout>
<ImageView
android:id="#+id/askscreen_submit_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:paddingTop="20dp"
android:src="#drawable/askftwa_submit_button" />
</LinearLayout>
</ScrollView>
Add more elements and the scroll will appear. Right now all the elements are fitting within the screen and that's why you don't see any scroll
First a fall by seeing your xml, you are creating very expensive layout containing
unnecessarily many Linear layouts ie when orientation of your all views are vertical.
Why are you defining your views like textbox and edittext in separate Linear Layouts,
it creates performance issues.
Secondly, you should not define set any background and orientation in scroll view.
By default orientation of scroll view is vertical.
Although i just run your code with few changes and its working fine on my emulator
and on my device.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
// This is Main layout which contains all your child view
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/home_bg"
android:orientation="vertical" >
// Define your remaining child views here.....
// And as i can see all views are oriented vertically, so you can define all view
inside this Main Layout itself.
// Accordingly you can set Margins of your views too.
</LinearLayout>
</ScrollView>

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