I designed a layout with four EditText and i want to facilitate the navigation of them. I understand the use of android:nextFocusDown but i'm not able to get it to work. I also setted the ´ImeOptions´ to actionNext, but on the softpad I neither see the right icon.
My XML snippet:
<EditText
android:id="#+id/reservation_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#drawable/edit_text_reservation"
android:ems="10"
android:hint="#string/yourName"
android:imeOptions="actionNext"
android:nextFocusDown="#+id/reservation_surname" >
</EditText>
<EditText
android:id="#+id/reservation_surname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#drawable/edit_text_reservation"
android:ems="10"
android:hint="#string/yourSurname"
android:imeOptions="actionNext"
android:nextFocusDown="#+id/reservation_email"
android:nextFocusUp="#+id/reservation_surname" />
<EditText
android:id="#+id/reservation_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#drawable/edit_text_reservation"
android:ems="10"
android:hint="#string/yourEmail"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:nextFocusDown="#+id/reservation_notes"
android:nextFocusUp="#+id/reservation_email" />
<EditText
android:id="#+id/reservation_notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edit_text_reservation"
android:ems="10"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:nextFocusUp="#id/reservation_notes" />
I had a similar issue, where nextFocus* simply did not work. In your case..
going from
<EditText android:id="#+id/reservation_name"...
android:nextFocusDown="#+id/reservation_notes"
to
change surname's id to NOT have a "+" i.e.
<EditText android:id="#id/reservation_surname"
this way you are
no creating a new reference to that tag.
This will now work.
Related
I am trying to implement AutoCompleteTextView with multiline text and with keyboard done button. But done button does not show on keyboard (shows enter button). Same thing i have tried with android:singleLine="true" and text comes in single line with done button.
<AutoCompleteTextView
android:id="#+id/txtVillageName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edt_border"
android:cursorVisible="true"
android:maxLines="4"
android:hint="Enter your location"
android:imeOptions="actionDone"
android:textColor="#color/text_color"
android:textColorHint="#color/lblColor"
android:textSize="#dimen/text_size_large" />
Add android:imeActionLabel="Done" into your xml code
<AutoCompleteTextView
android:id="#+id/txtVillageName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:hint="Enter your location"
android:imeOptions="actionDone"
android:imeActionLabel="Done"
android:singleLine="true" />
android:inputType="text" works.
<AutoCompleteTextView
android:id="#+id/txtVillageName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:hint="#string/location_hint"
android:imeOptions="actionDone"
android:inputType="text"
android:textColor="#color/text_color"
android:textColorHint="#color/lblColor"
android:textSize="#dimen/text_size_large" />
Set HorizontalScrolling and MaxLines
mAutocompleteTextView.setHorizontallyScrolling(false);
mAutocompleteTextView.setMaxLines(Integer.MAX_VALUE);
It works
I am creating an android application in which i am collecting user's some messages.But i am getting some issues such as following..
I have added 3 edit text in alert dialog..the third edit text box having multi line textbox so whenever i am adding multiple lines its getting overlapped to above two edit text
here is the snapshot of the error
Here Is Layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<ScrollView
android:layout_width="245dp"
android:layout_height="245dp"
android:layout_weight="0.40"
android:layout_gravity="center_horizontal">
<RelativeLayout
android:layout_width="245dp"
android:layout_height="200dp">
<EditText
android:layout_width="235dp"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/editText6"
android:layout_gravity="center_horizontal"
android:hint="Your Email Id"
android:layout_alignBaseline="#+id/editText5"
android:layout_alignBottom="#+id/editText5"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="240dp"
android:layout_height="wrap_content"
android:id="#+id/editText4"
android:layout_gravity="center_horizontal"
android:hint="Title"
android:singleLine="true"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="236dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText5"
android:hint="Description"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" /></RelativeLayout></ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:id="#+id/button10"
android:layout_gravity="center_horizontal" />
</LinearLayout>
Reason for your issue is android:inputType="textMultiLine" pushes content when there is a new line!
You can use android:maxLines="1" for your EditText [any way this will be useful for you since you have used android:singleLine="true" with is kind of dipricated ]
Ps: Hard coding android:maxLength will not solve your issue since screens can be in different sizes which makes you hard to decide how many lines you keep!
Also you can use android:maxHeight="xdp" for the editText view, then the limit won't exeed!
You should use
android:maxLength="4"
row numbers you want to fix for your edit text
Use LinearLayout with vertical orientation instead of RelativeLayout.
If u want to use RelativeLayout, then set layout_below attribute of RelativeLayout.
You need to set android:maxLines="4". Set your max lines to solve this issue.
<EditText
android:id="#+id/editText4"
android:maxLines="4"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="Title"
android:layout_alignParentStart="true" />
You can use android:layout_below and android:layout_marginTop in your EditText views and keep distance between your views.
Example :
<EditText
android:layout_width="236dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/editText5"
android:hint="Description"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/editText4"
android:layout_marginTop="20dp"/>
I have an Edittext wrapped inside a TextInputLayout. I tried using android:nextFocusForward="#+id/spinnerLanguage" so that i could gain the focus of the spinner. This doesn't work. I even tried using android:nextFocusUp and this method does not seem to work
<android.support.design.widget.TextInputLayout
android:id="#+id/txtEmailAddressWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:hint="EMAIL ADDRESS"
android:padding="5dp"
android:id="#+id/txtEmailAddress"
android:nextFocusForward="#+id/spinnerLanguage"
android:inputType="text"
android:maxLength="40" />
</android.support.design.widget.TextInputLayout>
<fr.ganfra.materialspinner.MaterialSpinner
android:id="#+id/spinnerLanguage"
android:layout_width="match_parent"
app:ms_floatingLabelColor="#color/colorAccent"
android:layout_height="wrap_content"
app:ms_enableFloatingLabel="true"
app:ms_hint="LANGUAGE" />
try with this
txtEmailAddress.setFocusableInTouchMode(true);
or
txtEmailAddress.setFocusable(false);
and use this to clear focous
txtEmailAddress.clearFocus();
or use this in xml
android:focusable="true"
android:focusableInTouchMode="true"
may be this will help you
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="Password"
/>
This is the code I have in my xml file, the line android:inputType="textPassword" from my understanding is supposed to make the text entered in the field appear hidden. When run on and android device the text is not hidden.
Try this :
<EditText
android:layout_height="wrap_content"
android:gravity="center"
android:password="true"
android:layout_width="match_parent"
android:id="#+id/password"
android:hint="password"
android:maxLines="1">
</EditText>
I've a EditText and a AutoCompleteTextView and the text starts not on the same position which looks a bit strange.
I'm using appcompat v7 and I don't know if it's possible to fix this.
The line in the bottom is also different (so so bad as the text begin)
I also tried to style it like appcompat's EditText, but that doesn't look like that.
Code
<EditText
android:id="#+id/input_ipAdresse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignEnd="#+id/button_berechnen"
android:layout_alignRight="#+id/button_berechnen"
android:ellipsize="end"
android:gravity="start"
android:hint="#string/input_ipAdresse"
android:imeOptions="flagNoExtractUi"
android:inputType="phone"
android:paddingStart="#dimen/padding_small"
android:paddingEnd="#dimen/padding_small"
android:textSize="#dimen/fontsize_medium" >
<requestFocus android:layout_width="match_parent" />
</EditText>
<AutoCompleteTextView
android:id="#+id/input_snm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_below="#+id/input_ipAdresse"
android:ellipsize="end"
android:gravity="start"
android:imeActionLabel="#string/Button_berechnen"
android:imeOptions="actionDone|flagNoExtractUi"
android:inputType="phone"
android:paddingStart="#dimen/padding_small"
android:paddingEnd="#dimen/padding_small"
android:textSize="#dimen/fontsize_medium" />