Android EditText cannot focus when the keyboard is showing - android

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

Related

Android layout : trying to add an edittext above a listview

I am trying to add an edittext above a listview. The edittext field gets displayed, however, it is repeated for each row in the listview as well, which I don't want.
I have tried placing it outside the first inner LinearLayout but there is no difference in the behaviour.
Can someone please help me to figure out what I might be doing wrong.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/llMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:orientation="vertical">
<EditText
android:id="#+id/searchString"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="#drawable/abc_ic_clear_holo_light"
android:ems="10"
android:hint="Search for..."
android:text="" >
</EditText>
<ListView
android:id="#+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="3sp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvCategory"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingRight="1sp"
android:text=""
android:textColor="#FFFFFF"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tvCategory"
android:paddingRight="1sp"
android:text=""
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView7"
android:paddingRight="1sp"
android:text=""
android:textColor="#000000"
android:textSize="14sp" />
<TextView
android:id="#+id/textView8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/textView5"
android:gravity="right"
android:paddingRight="1sp"
android:text=""
android:textColor="#000000"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/idAdView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight="1"
android:orientation="vertical" />
</LinearLayout>
Try adding the edit text as header view to the list.
public void addHeaderView (View v)
Ref : http://developer.android.com/reference/android/widget/ListView.html#addHeaderView(android.view.View)

Words get cut of in Android ListView

I'm stuck with a small problem in my listview. I tried several things like adding padding or changing the margins. But this didn't fix my problem.
Words keep getting cut of in the last rule.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:divider="?android:dividerVertical"
android:showDividers="middle"
android:dividerPadding="8dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/violationstitlebar"
>
<TextView
android:layout_width="#dimen/violation_list_col1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolPos"/>
<TextView
android:layout_width="#dimen/violation_list_col2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolDescriptionNLB"/>
<TextView
android:layout_width="#dimen/violation_list_col3"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:layout_width="#dimen/violation_list_col4"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskDescriptionFRB" />
<TextView
android:layout_width="#dimen/violation_list_col5"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:layout_width="#dimen/violation_list_col6"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolBLS"/>
<TextView
android:layout_width="#dimen/violation_list_col7"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolRepeat"
/>
<TextView
android:layout_width="#dimen/violation_list_col8"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:divider="?android:dividerVertical"
android:showDividers="middle"
android:dividerPadding="8dp"
>
<TextView
android:layout_width="#dimen/violation_list_col1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/tvViolListPosition"
android:paddingLeft="10dp"
android:paddingBottom="10dp"/>
<TextView
android:layout_width="#dimen/violation_list_col2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/tvViolListDescription"
android:layout_weight="1"
android:maxLines="4"
/>
<ImageButton
android:layout_width="#dimen/violation_list_col3"
android:layout_height="50dp"
android:id="#+id/ibViolListEditDesc"
/>
<TextView
android:layout_width="#dimen/violation_list_col4"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/tvViolListDescriptionFRB"
android:layout_weight="1"
/>
<ImageButton
android:layout_width="#dimen/violation_list_col5"
android:layout_height="50dp"
android:id="#+id/ibViolListEditDescFRB"
/>
<Spinner
android:layout_width="#dimen/violation_list_col6"
android:layout_height="wrap_content"
android:id="#+id/spViolListConclusion"
style="?android:dropDownSpinnerStyle"/>
<EditText
android:layout_width="#dimen/violation_list_col7"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/etViolListCounter"
android:inputType="number"
/>
<ImageButton
android:layout_width="#dimen/violation_list_col8"
android:layout_height="50dp"
android:id="#+id/ibViolListDelete"
/>
</LinearLayout>
</LinearLayout>
Does anyone have an idea how to fix this?
kind regards,
Tim
give some limitaion to charaters ,while adding the content of your NLB
maxlines, minimum lines
<EditText
android:id="#+id/AddressEdittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="15dp"
android:background="#drawable/retangle_shape"
android:gravity="top|left"
android:hint="Type Here..."
android:inputType="textMultiLine"
android:lines="5"
android:maxLines="10"
android:minLines="5"
android:paddingBottom="5dp"
android:paddingLeft="#dimen/padding"
android:paddingRight="#dimen/padding"
android:paddingTop="5dp"
android:scrollbars="vertical" >
</EditText>
Try using this property also with some padding bottom:
android:includeFontPadding="false"
And:
android:baselineAligned="false"
I think you can solve it with layout_weight attribute.
More info on layout_weight can be found on:
http://ugia.io/2012/01/19/android-linearlayout-distribution-explained-weight-and-sizes/
http://developer.android.com/guide/topics/ui/layout/linear.html

keyboard doesn't display in android popup view

I've got a popup layout inflator with EditText fields. It is opened inside my activity when a button is pressed. I then ask for input information through the popup window. When I press any of the EditText fields the keyboard doesn't display. Does the popup View not support interaction?
Here is my xml:
<?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="#android:color/background_light">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_margin="1dp"
android:background="#android:color/darker_gray">
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Fill in the information." />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Field ID or Name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/fieldname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_below="#+id/textView1"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/enterWidth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Width of Implement - Feet or Meters"
android:layout_below="#+id/fieldname"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/width"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_below="#+id/enterWidth"
android:inputType="numberDecimal" />
<TextView
android:id="#+id/units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Units"
android:layout_below="#+id/width"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioGroup
android:id="#+id/radiogroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/units"
android:orientation="vertical">
<RadioButton android:id="#+id/standard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Standard - feet, ac, mph"
android:onClick="onRadioButtonClicked"/>
<RadioButton android:id="#+id/metric"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Metric - m, ha, kph"
android:onClick="onRadioButtonClicked"/>
</RadioGroup>
<TextView
android:id="#+id/comments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Field Comments"
android:layout_below="#+id/radiogroup"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/commentlines"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/comments"
android:ems="10"
android:inputType="textMultiLine" />
</RelativeLayout>
<Button
android:id="#+id/startbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Begin Spraying" />
</LinearLayout>
</LinearLayout>
After digging I found this similar post:
EditText On A Popup Window
The key is to make the PopupWindow focusable.
This can be done by:
popupWindow.setFocusable(true);

auto grow edittext below buttons above keybord

Yet another same problem for android which drive developers crazy!
I want to make buttons above keyboard...
Here is my xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/home"
android:layout_width="910dp"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:keepScreenOn="true"
android:orientation="vertical"
android:padding="15dip" >
<com.custom.webview
android:id="#+id/webView1"
android:layout_width="900dp"
android:layout_height="350dp"
android:visibility="gone" >
</com.custom.webview>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:paddingBottom="5dip"
android:paddingTop="20dip"
android:text="#string/choose_the_outcome"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="25sp" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:entries="#array/call_outcomes" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:paddingBottom="5dip"
android:paddingTop="20dip"
android:text="#string/notes"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="25sp" />
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="sans-serif-light"
android:inputType="textMultiLine" >
</EditText>
<LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="25dip" >
<Button
android:id="#+id/button1"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:onClick="onCancel"
android:text="#android:string/cancel" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:onClick="onSave"
android:text="#string/save" />
</LinearLayout>
</LinearLayout>
just move all your layoouts as they are in the RelativeLayout. It might fix an issue.
Add this line
android:windowSoftInputMode="adjustResize|stateHidden"
to AndroidManifest.xml <activity> tag
You need to to do the following:
Just Make the text view child of a spinner
or put text view height = wrap_content.

Next Button in Keyboard is not showing

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"

Categories

Resources