edittext hides behind titlebar when soft keyboard is visible - android

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.

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

add adjustPan in manifest under activity tag
android:windowSoftInputMode="adjustResize|adjustPan"

Related

A relative layout inside of a scrollview isn't scrollable

Im trying to make a UI with a few fields in the middle of the screen and a button at the bottom. When i am writing a number in the fields, the keyboard hides part of the interface (which i want it to), but i also need the whole interface to be scrollable so that i can adjust the screen and keep filling the fields with the keyboard on. I've put the whole setup in a relative layout and put it under a scroll view. The posts here say it should work that way but it isnt working for me.
The XML code is
<?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"
tools:context="com.example.maaz.rakattracker.MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<EditText
android:id="#+id/farzET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:gravity="center"
android:hint="0"
android:inputType="number"
android:singleLine="true"
android:textAlignment="center" />
<TextView
android:id="#+id/farzLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:elevation="0dp"
android:ems="5"
android:text="farz"
android:textAlignment="center"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<EditText
android:id="#+id/sunnatET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="0"
android:inputType="number"
android:singleLine="true"
android:textAlignment="center" />
<TextView
android:id="#+id/sunnatLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:text="Sunnat"
android:textAlignment="center"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<EditText
android:id="#+id/naflET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:gravity="center"
android:hint="0"
android:inputType="number"
android:singleLine="true"
android:textAlignment="center" />
<TextView
android:id="#+id/naflLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:text="Nafl"
android:textAlignment="center"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<EditText
android:id="#+id/witrET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="0"
android:inputType="number"
android:singleLine="true"
android:textAlignment="center" />
<TextView
android:id="#+id/witrLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="5"
android:text="Witr"
android:textAlignment="center"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/startButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Button" />
</RelativeLayout>
</ScrollView>
Kindly help me figure out the issue here.
Thanks
Try to add this code in your Activity inside onCreate() method :
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_ADJUST_PAN);
In your manifest, add android:windowSoftInputMode="adjustResize" to your Activity tag.
On your manifest file add
<activity
android:name=".YOURACTIVITY"
android:windowSoftInputMode="adjustPan" />
<activity
that because scroll view work only with LinearLayout

Move Layout Up when Soft Keyboard appears

I have login page with Email Id ,Password & LOGIN button. Right now when any one of the Edit Text gain focus then system keyboard hides my Login button. I want to push my layout above when keyboard appears keeping LOGIN button above of keyboard.
P.S I've tried all solution like
adjust Pan|adjust Resize, adjust Pan,adjust Resize"
in manifest as well as in Java code
But none of thing worked for me.
<ScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/newl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="145dp"
android:drawablePadding="8dp"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_clock"
android:id="#+id/clock"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Timetracker"
android:fontFamily="LucidaGrande"
android:textSize="30dp"
android:textAlignment="center"
android:layout_marginTop="15dp"
android:layout_gravity="center_horizontal"
android:id="#+id/tt"
android:layout_below="#+id/clock"
android:textColor="#FFFFFF"
android:layout_centerHorizontal="true"
/>
<LinearLayout
android:layout_below="#+id/tt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="30dp"
>
<ImageView
android:layout_marginLeft="7dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_person_black_24dp"
android:layout_centerVertical="true"
/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#FFFFFF"
android:layout_marginLeft="9dp"
android:drawablePadding="12dp"
android:textSize="15dp"
android:layout_marginRight="45dp"
android:fontFamily="Sans Serif"
android:layout_centerInParent="true"
android:textColor="#FFFFFF"
android:background="#android:color/transparent"
android:id="#+id/spinner2"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_drop_down_black_24dp"
android:layout_alignParentRight="true"
android:paddingRight="8dp"
android:layout_centerVertical="true"/>
</RelativeLayout>
<View
android:layout_below="#+id/rel"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_height="1dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/lock"
android:drawablePadding="12dp"
android:layout_marginTop="30dp"
android:layout_below="#+id/rel"
android:layout_marginRight="7dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="7dp"
android:hint="Password"
android:background="#android:color/transparent"
android:textColorHint="#FFFFFF"
android:textSize="20dp"
android:textColor="#FFFFFF"
android:id="#+id/editText"
android:inputType="textPassword"
android:backgroundTint="#FFFFFF"
/>
<View
android:layout_below="#+id/editText"
android:layout_width="match_parent"
android:background="#FFF"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_height="1dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_below="#+id/editText"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:background="#FFFFFF"
android:text="LOG IN"
android:id="#+id/log"
android:textColor="#D04045"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
The solution was to use android:fillViewport="true" on the ScrollView.
and with this you can also use android:windowSoftInputMode="adjustResize"
this worked for me
try this,
Add the below line in your manifest file,
android:windowSoftInputMode="adjustResize"
For example,
<activity android:name=".Game" android:windowSoftInputMode="adjustResize">
</activity>

Scrollview doesn't show full content [Android]

I have a problem with Scrollview on Android. The problem is showing all content in a register form.
XML Layout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/app_background"
tools:context=".RegisterActivity"
xmlns:tools="http://schemas.android.com/tools">
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="#string/register_header"
android:textSize="30sp"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginBottom="30dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_loginField"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18sp"
android:layout_marginBottom="8dp"
/>
<EditText
android:id="#+id/register_input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:textColor="#000000"
android:hint="#string/hint_login"
android:layout_marginBottom="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_password"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18sp"
android:layout_marginBottom="20dp"
/>
<EditText
android:id="#+id/register_input_passw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textColor="#000000"
android:hint="#string/hint_passw"
android:layout_marginBottom="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_repeatpass"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18sp"
android:layout_marginBottom="20dp"
/>
<EditText
android:id="#+id/register_input_passwre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textColor="#000000"
android:hint="#string/hint_passw"
android:layout_marginBottom="20dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_gender"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18sp"
android:layout_marginBottom="20dp"
/>
<RadioGroup
android:id="#+id/register_radiog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RadioButton
android:id="#+id/register_radioM"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_gMale"
android:textSize="16sp"
/>
<RadioButton
android:id="#+id/register_radioF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_gFemale"
android:textSize="16sp"
android:layout_marginBottom="20dp"
/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_name"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18sp"
/>
<EditText
android:id="#+id/register_input_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textColor="#000000"
android:hint="#string/hint_name"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_age"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18sp"
/>
<EditText
android:id="#+id/register_input_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textColor="#000000"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/register_input_termsofuse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_termsofuse"
android:textSize="16sp"
android:textColor="#000000"
android:textStyle="bold"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/register_btSignup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#fc9a24"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:text="#string/register_btSignup"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="#FFFFFF"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
But when I execute in my Android device I can't see the register_header textview.
Also when I click on one EditText, my device show keyboard, and all view is pushed up, hidding more items (email textview and edittext).
How can I solve this?
In this first image, as you can see header isn't showing. This is bad...
In this second image, I can scroll and see register button, this is good.
And in this third image, when keyboard appears and I go to top of the scrollview I can't see the register_header, the email input and email textview
How can I, fix layout position (not push up when keyboard appears) and show all content inside Scrollview.
Thx
Add this to your activity in your manifest
<activity android:windowSoftInputMode="adjustPan"> </activity>
The activity's main window is not resized to make room for the soft
keyboard. Rather, the contents of the window are automatically panned
so that the current focus is never obscured by the keyboard and users
can always see what they are typing. This is generally less desirable
than resizing, because the user may need to close the soft keyboard to
get at and interact with obscured parts of the window.

issue in Android keyboard overlap edittext [duplicate]

This question already has answers here:
Keyboard overlapping EditText on click
(2 answers)
Closed 5 years ago.
main.xml
<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"
android:background="#drawable/loginbg"
tools:context="com.demo.waypointstest.MainActivity$PlaceholderFragment" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_above="#+id/txt_visit_site"
android:gravity="bottom" >
<ImageView
android:id="#+id/img_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/loginlogo"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/img_logo"
android:layout_marginLeft="30dp"
android:layout_marginTop="5dp"
android:text="Sign In"
android:textColor="#312f2f"
android:textStyle="normal"
android:textSize="#dimen/text_16" />
<TextView
android:id="#+id/new_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/img_logo"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:drawablePadding="5dp"
android:drawableLeft="#drawable/signup"
android:text="Free Sign up"
android:textColor="#4f4d4d"
android:textSize="#dimen/text_13" />
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="5dp"
android:ems="10"
android:textColor="#android:color/black"
android:hint="Email"
android:padding="10dp"
android:singleLine="true"
android:textColorHint="#696969"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_15" >
</EditText>
<RelativeLayout
android:id="#+id/rel_pass"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText1"
android:layout_below="#+id/editText1" >
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_toLeftOf="#+id/button1"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#android:color/black"
android:padding="10dp"
android:singleLine="true"
android:textColorHint="#696969"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/text_15" />
<TextView
android:id="#+id/button1"
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:background="#drawable/rect_login"
android:gravity="center"
android:layout_alignBottom="#+id/editText2"
android:padding="5dp"
android:layout_marginBottom="3dp"
android:drawablePadding="5dp"
android:text="LOG IN"
android:drawableLeft="#drawable/log_right"
android:textColor="#android:color/white"
android:textSize="#dimen/text_15"
android:textStyle="normal" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/rel_rem_fg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rel_pass"
android:layout_marginTop="5dp" >
<CheckBox
android:id="#+id/chk_rem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="5dp"
android:button="#drawable/checkbox_selector"
android:gravity="center"
android:text="Remember me"
android:textColor="#3a3939"
android:textSize="#dimen/text_14" />
<TextView
android:id="#+id/forgot_pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:text="#string/fgp"
android:textColor="#3a3939"
android:textSize="#dimen/text_14" />
</RelativeLayout>
</RelativeLayout>
<TextView
android:id="#+id/txt_visit_site"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/site"
android:layout_marginBottom="5dp"
android:textColor="#5A6F5A"
android:textSize="#dimen/text_12" />
</RelativeLayout>
in Manifest file i set android:windowSoftInputMode property as
android:windowSoftInputMode="adjustResize"
EDIT
i want keyboard below of bottom text like which write for more info visit
but still keyboard overlap in my edittext any idea how can i solve it?
EDIT 1
I was facing the same issue. I just removed android:windowSoftInputMode="..."
from manifest and it worked great.
Sorry for posting answer instead of comment due to less reputation :)
Try this . you need to set an android:windowSoftInputModeattribute to adjustResize in Manifest and put your layout(from root RelativeLayout ) inside a ScrollView.
<activity
android:name="..."
android:windowSoftInputMode="adjustResize">
</activity>
See developer docs for more discussion.

Space to right and left inside EditText

I'm trying to create an EditText with 2 buttons inside (right and left). I want to give it a padding on each side so that the text not appears behind the buttons. But I can not. I tried with padding, margin... but nothing works for me. What can be the error?
<LinearLayout
android:id="#+id/buscar_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:orientation="horizontal"
android:visibility="gone" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/buscar_monumento"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="15"
android:gravity="center_horizontal"
android:hint="Buscar..."
android:imeOptions="actionDone"
android:inputType="text"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:textColor="#color/negro"
android:textStyle="bold" >
</EditText>
<Button
android:id="#+id/buscar_lupa"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="7dp"
android:background="#drawable/buscar_lupa" />
<Button
android:id="#+id/buscar_salir"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="7dp"
android:background="#drawable/buscar_salir" />
</FrameLayout>
</LinearLayout>
NEW CODE
<LinearLayout
android:id="#+id/buscar_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:orientation="horizontal"
android:visibility="gone" >
<EditText
android:id="#+id/buscar_monumento"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="15"
android:gravity="center_horizontal"
android:hint="Buscar..."
android:imeOptions="actionDone"
android:inputType="text"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:textColor="#color/negro"
android:textStyle="bold" >
</EditText>
<Button
android:id="#+id/buscar_lupa"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="7dp"
android:background="#drawable/buscar_lupa" />
<Button
android:id="#+id/buscar_salir"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="7dp"
android:background="#drawable/buscar_salir" />
</LinearLayout>
don't use FrameLayout, use RelativeLayout instead
framelayout is best used for single item, or wrap LinearLayout around the Button and TextView if you insists on using FrameLayout
or better, change the parent viewgroup LinearLayout to RelativeLayout, else the ADT will tell a warning about the useless viewgroup
If you just need two buttons on the sides of edit text simplest way is this
<LinearLayout
android:id="#+id/buscar_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:orientation="horizontal">
<Button android:background="#drawable/ic_launcher"
android:id="#+id/buscar_lupa"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="7dp"/>
<EditText
android:id="#+id/buscar_monumento"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:ems="15"
android:gravity="center_horizontal"
android:hint="Buscar..sdsdsdsds."
android:text="1234567890123456789012345678901234567890"
android:imeOptions="actionDone"
android:inputType="text"
android:textColor="#f00"
android:textStyle="bold" >
</EditText>
<Button android:background="#drawable/ic_launcher"
android:id="#+id/buscar_salir"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="7dp"/>
</LinearLayout>
First of all in your new code segment you have the parent linear layout visibility set to gone
Secondly use a relative layout it's simple
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="#+id/buscar_monumento"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="15"
android:hint="Buscar..."
android:imeOptions="actionDone"
android:inputType="text"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:textColor="#color/negro"
android:textStyle="bold" >
</EditText>
<Button
android:id="#+id/buscar_lupa"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/buscar_lupa" />
<Button
android:id="#+id/buscar_salir"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="7dp"
android:background="#drawable/buscar_salir" />

Categories

Resources