I want when user type then instead of arrow key it should show the next button in keyboard.
So user not need to press the back to input next edittext.
Added the Layout:
<?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="match_parent"
android:background="#D5D5D5"
android:orientation="vertical" >
<FrameLayout
android:id="#+id/topLinearLayout"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:background="#drawable/bar" >
<ImageView
android:id="#+id/new_quote_imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/new_quote_bar" />
<TextView
android:id="#+id/contactUs"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/contact_us"
android:textColor="#android:color/white"
android:textSize="15sp" />
</FrameLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight=".7"
android:background="#EEEBE6"
android:orientation="vertical"
android:padding="15dip" >
<TextView
android:id="#+id/nameTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:text="#string/name"
android:textColor="#android:color/black"
android:textSize="16sp" />
<EditText
android:id="#+id/nameEditText"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_marginTop="10dip" />
<TextView
android:id="#+id/emailTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:text="#string/email"
android:textColor="#android:color/black"
android:textSize="16sp" />
<EditText
android:id="#+id/emailEditText"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_marginTop="10dip"
android:inputType="textEmailAddress" />
<TextView
android:id="#+id/commentsTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:text="#string/comments"
android:textColor="#android:color/black"
android:textSize="16sp" />
<EditText
android:id="#+id/commentsEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:lines="5" />
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="5dip"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dip"
android:layout_marginTop="10dip"
android:gravity="right|center_vertical"
android:weightSum="1" >
<Button
android:id="#+id/submitButton"
android:layout_width="0dip"
android:layout_height="35dip"
android:layout_weight=".3"
android:background="#drawable/button_background"
android:text="#string/submit"
android:textColor="#android:color/white"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
Please help me for this.
Thanks in advance.
add this line to your edittext xml
android:singleLine="true"
If you don't want multiple line simple add
android:singleLine="true"
else please use this given solution
<EditText
android:id="#+id/commentsEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:imeOptions="actionNext"
android:lines="5" />
I have added
android:imeOptions="actionNext"
this line extra, use this in every EditText that you want have next button in soft key Board
Define inputType for each edit text.
<EditText
android:id="#+id/editText"
android:inputType="textPersonName" />
Try adding this to the edit text:
android:singleLine="true"
android:singleLine="true" //deprecated
use android:maxLines="1" & imeOptions
android:maxLines="1"
android:imeOptions="actionNext"
Simply use
android:inputType="textNoSuggestions"
android:maxLines="1"
and remove if you have used digits.
android:digits
Add below line in your edittext
android:imeOptions="flagNavigateNext"
Example given below:
<EditText
android:id="#+id/commentsEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:lines="5"
android:imeOptions="flagNavigateNext"/>
Try adding this
android:imeOptions="flagNavigateNext"
android:inputType="text"
Related
EditText's hint gets cut off because my hint text is longer than one line. The editText only displays one line. How can I make the whole hint visible?
This is the editText that gives me troubles.
<EditText android:id="#+id/pin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:hint="#string/pinhintadmin"
android:maxLength="4"
android:layout_margin="10dip"
android:layout_marginBottom="20dip"/>
Here is my whole xml file.
<LinearLayout 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:orientation="vertical"
android:background="#drawable/background1" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/burr"
android:textStyle="bold"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="20dip"/>
<EditText android:id="#+id/flob"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/buildingnameandaddress"
android:inputType="textCapWords"
android:layout_margin="10dip"
android:layout_marginBottom="20dip"/>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/appartment"
android:textStyle="bold"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="20dip"/>
<EditText android:id="#+id/txtName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/hintapp"
android:layout_margin="10dip"
android:inputType="textCapSentences"
android:layout_marginBottom="20dip"/>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Pin:"
android:textStyle="bold"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="20dip"/>
<EditText android:id="#+id/pin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:hint="#string/pinhintadmin"
android:maxLength="4"
android:layout_margin="10dip"
android:layout_marginBottom="20dip"/>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/username"
android:textStyle="bold"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"/>
<EditText android:id="#+id/txtEmail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:layout_margin="10dip"
android:layout_marginBottom="20dip"/>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/password"
android:textStyle="bold"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="20dip"/>
<EditText android:id="#+id/registerPassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:layout_marginBottom="20dip"/>
<Button
android:id="#+id/btnRegister"
android:text="#string/registerbtnadmin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:textStyle="bold"
android:background="#drawable/button_red"
android:textColor="#drawable/button_text_color" />
<!-- Error message -->
<TextView android:id="#+id/register_error"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#e30000"
android:padding="10dip"
android:textStyle="bold"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
You can try
android:scrollHorizontally="true"
as referenced here
Or
You can try this
view.setHint(Html.fromHtml("<small><small><small>" +
getString(R.string.hint) + "</small></small></small>"));
as accepted answer here
Add android:inputType="textMultiLine" in your XML:
<EditText
android:inputType="textMultiLine"
style="#style/TextAppearance.AppCompat.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:autofillHints="personName"
android:background="#null"
android:hint="Enter first name"
android:maxLength="25"/>
If you have a long line of string for the hint of the eddittext you can put a new line character to the place where the new line occurs
sample:
android:hint="first line \n second line"
Try to use \n in the string.
<string name="pinhintadmin">line one \n line two </string>
or try using android:scrollHorizontally="true"
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
I have an activity that allows me to enter content. It consists of edit text and button bar. Whenever I what to input something to the edit text, a keyboard pops up and the button bar is on top if it so I can't see what I'm typing if the content is long(it goes behind the button bar). How can i fix it ?
my code is:
<RelativeLayout
android:id="#+id/toplayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#drawable/notetop"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingTop="5dp" >
<TextView
android:id="#+id/title_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18sp" />
<EditText
android:id="#+id/etTitleJoke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/title_text1"
android:background="#android:color/transparent"
android:hint="#string/no_title"
android:imeOptions="actionNext"
android:singleLine="true"
android:textColor="#000000"
android:textSize="18sp" >
</EditText>
</RelativeLayout>
<view
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/etContentJoke"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toplayout"
class="ie.myjokes.LineEditText"
android:background="#android:color/transparent"
android:capitalize="sentences"
android:scrollHorizontally="true"
android:fadingEdge="vertical"
android:gravity="top"
android:padding="5dp"
android:scrollbars="vertical"
android:textColor="#000000"
android:textSize="22sp" >
<requestFocus />
</view>
<LinearLayout
android:id="#+id/footer"
style="#android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="#+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickSave"
android:text="#string/btn_save"
android:textColor="#000000" />
<Button
android:id="#+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickCancel"
android:text="#string/btn_cancel"
android:textColor="#000000" />
</LinearLayout>
nevermind, I added this line into my activity and its gone now. Thank you
android:windowSoftInputMode="adjustPan"
I have a problem on the EditText. I cannot show all the EditText field when the soft keyboard is showing, just like the following image:
And the following is my layout code:
<?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"
android:padding="15dip"
android:focusable="true" >
<TextView
android:id="#+id/password_listing"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="#string/new_service"
android:textSize="20dip"
android:textStyle="bold"
android:padding="10dip" />
<RelativeLayout
android:id="#+id/l_service_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical" >
<TextView
android:id="#+id/service_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:text="#string/service_name"
android:textSize="15dip"
android:textStyle="bold" />
<EditText
android:id="#+id/servicename"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal"
android:hint=""
android:singleLine="true"
android:focusable="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/l_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical" >
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:text="#string/username"
android:textSize="15dip"
android:textStyle="bold" />
<EditText
android:id="#+id/username"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal"
android:hint=""
android:singleLine="true"
android:focusable="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/l_pwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical" >
<TextView
android:id="#+id/pwdset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:text="#string/pwd_txt"
android:textSize="15dip"
android:textStyle="bold" />
<EditText
android:id="#+id/pwd_set"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal"
android:hint=""
android:inputType="textPassword"
android:isScrollContainer="true"
android:focusable="true" />
</RelativeLayout>
<LinearLayout
android:id="#+id/layout_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_vertical|center_horizontal" >
<TextView
android:id="#+id/selectmsg_txt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="#string/selectmsg"
android:textSize="15dip"
android:textStyle="bold" />
<GridView
android:id="#+id/app_grid"
android:layout_width="match_parent"
android:layout_height="150dp"
android:padding="10dp"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:columnWidth="60dp"
android:stretchMode="columnWidth"
android:gravity="center" />
<Button
android:id="#+id/b_addpwd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:text="#string/add"
android:background="#android:color/transparent"
android:drawableLeft="#drawable/ic_add"
android:textColor="#android:color/white"
android:textSize="20dip" />
</LinearLayout>
</LinearLayout>
Since I want it auto-hidden the soft keyboard when I enter this activity, so I added this into my activity:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
What is the problem with my layout xml?
use a scroll view and also add following in the activity tag in manifest file:
android:windowSoftInputMode="adjustPan"
Use the following code snippet in your manifest file :
android:windowSoftInputMode="adjustResize|adjustPan"
What helped me is this:
EditText et = new EditText(); //or whatever way you use to fetch the object
et.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
Hope it'll help you as well
I have a login screen as shown in the picture.
When the soft key comes it hides the Login button. I need the button moves to the top of the soft key so that the user can click after entering the id and password.
Below is the layout......
<?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:background="#drawable/background" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="50dp" >
<EditText
android:id="#+id/email_mob_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="E-MAIL"
android:layout_marginBottom="-1dp"
android:singleLine="true"
android:background="#drawable/edit_text_top_boarder"
android:paddingLeft="5dp"
android:textColor="#2c2a29"
android:inputType="textEmailAddress"
android:imeOptions="flagNavigateNext">
</EditText>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_seperator"/>
<EditText
android:id="#+id/password_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="PASSWORD"
android:singleLine="true"
android:textColor="#2c2a29"
android:background="#drawable/table_cell_bottom"
android:paddingLeft="5dp"
android:imeOptions="actionDone"/>
</LinearLayout>
<TextView
android:id="#+id/forgot_password_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:textSize="16sp"
android:text="Glemt Password?"
android:textColor="#ffff"/>
<TextView
android:id="#+id/invalid_alert_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="Husk at udfylde e-mail/mobilnummer og password"
android:visibility="invisible"
android:textSize="16sp"
android:textColor="#ff0000"/>
<Button
android:id="#+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:layout_gravity="center"
android:background="#drawable/login_xml"
android:textColor="#ffffff"/>
</LinearLayout>
set softinputmode to adjustpan|adjust-resize by adding following line to activity tag:
android:windowSoftInputMode="adjustResize|adjustPan"