Display only single line at a time, in a Multiline Edittext - android

I have tried android:singleLine, maxLines, lineSpacing attributes but my EditText always displays a part of next line. How can I force it to display a single line at a time?
<EditText
android:layout_width="match_parent"
android:layout_height="30dp"
android:id="#+id/formulaView"
android:textColor="#000000"
android:textCursorDrawable="#drawable/visible_cursor"
android:background="#ffffff"
android:layout_marginTop="1dp"
android:textSize="18sp"
android:maxHeight="30dp"
android:gravity="center_vertical"
android:layout_marginBottom="1dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:scrollbars="vertical"
android:imeOptions="actionNext"
android:completionThreshold="1"
android:inputType="textMultiLine|textNoSuggestions"/>

Don't Use
android:inputType="textMultiLine|textNoSuggestions"
Instead use:
android:inputType="textNoSuggestions"
Code:
<EditText
android:layout_width="match_parent"
android:layout_height="30dp"
android:id="#+id/formulaView"
android:textColor="#000000"
android:background="#ffffff"
android:layout_marginTop="1dp"
android:textSize="18sp"
android:text="=SUM(android,Hello,How,Are,You) GoodMorining"
android:maxHeight="30dp"
android:gravity="center_vertical"
android:layout_marginBottom="1dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:scrollbars="vertical"
android:imeOptions="actionNext"
android:completionThreshold="1"
android:singleLine="true"
android:inputType="textNoSuggestions"/>
Hope this will help.
Have a great day ahead.

Related

Android, EditText, prevent line wrapping

I have an EditText component:
<EditText
android:id="#+id/LogDisplay"
android:layout_width="0dp"
android:layout_height="0dp"
android:ems="10"
android:fadeScrollbars="true"
android:gravity="start|top"
android:importantForAutofill="no"
android:inputType="textMultiLine|textNoSuggestions"
android:isScrollContainer="true"
android:nestedScrollingEnabled="true"
android:overScrollMode="always"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideInset"
android:scrollbars="horizontal|vertical"
android:scrollHorizontally="true"
android:singleLine="true"
android:verticalScrollbarPosition="right"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="LabelFor,SpeakableTextPresentCheck" />
Can't get the result to show a horizontal scroll bar and lines of text to show full length without hyphens.
Help me please.
To add a horizontal scroll to edit text, add this to your edit text:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/et_name_signup"
android:paddingLeft="5dp"
android:layout_marginTop="2dp"
android:singleLine="true"
android:background="#android:color/transparent"
android:scrollHorizontally="true"/>

How do I increase the size of EditText dynamically in android?

I want the height of EditText to be increased dynamically as per the size of text inputted.
Just like Whatsapp.
Here is what i am doing now!
<LinearLayout
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="44dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<EditText
android:textSize="15dp"
android:textColor="#000000"
android:hint="Enter New Note"
android:textColorHint="#8B111111"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center_vertical"
android:gravity="center"
android:imeOptions="actionDone"
android:layout_marginTop="8dp"
android:contentDescription="Enter Input Here"
android:layout_marginBottom="8dp"
android:id="#+id/editextNew"/>
</LinearLayout>
Please try this :
<LinearLayout
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<EditText
android:textSize="15dp"
android:textColor="#000000"
android:hint="Enter New Note"
android:maxLines="40"
android:lines="20"
android:textColorHint="#8B111111"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:imeOptions="actionDone"
android:layout_marginTop="8dp"
android:contentDescription="Enter Input Here"
android:layout_marginBottom="8dp"
android:id="#+id/editextNew"/>
</LinearLayout>
The only change you have to make (both occurrence):
android:layout_height="wrap_content"
Because you're giving it a fixed_height. Change that to wrap_content and it should work.
You can add android:maxLines to limit how much it expands.

Focus on last edittext in Custom Dialog doesn't work

In my App I'm using a Custum Dialog (android.app.Dialog) with three Edit Texts in it. I'm able to set the next focus from the first to the second EditText when I press the next Button on the SoftKeyboard, but it doesen't work to set the focus on the third EditText. I already tried to set nextFocusForward or nextFocusDown and so on but it still doesn't work.
Here is the XML Layout from my Custom Dialog:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/addcard_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/dialog_addcard_info" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/addcard_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:hint="#string/name"
android:inputType="text"
android:lines="1"
android:maxLines="1"
android:scrollHorizontally="true" />
<EditText
android:id="#+id/addcard_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:hint="#string/number"
android:inputType="number"
android:maxLength="16"
android:scrollHorizontally="true"/>
<EditText
android:id="#+id/addcard_pin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:hint="#string/pin"
android:inputType="numberPassword"
android:maxLength="4"
android:textSize="14sp"
android:scrollHorizontally="true"/>
</LinearLayout>
<TextView
android:id="#+id/addcard_errormessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="#string/error"
android:textColor="#ff0000"
android:textStyle="bold"
android:visibility="gone" />
<Button
android:id="#+id/addcard_verify"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="#string/verify" />
</LinearLayout>
Does anyone have an idea why i'm not able to set the focus on the third EditText?
Thanks in advance.
try this one in your code :)
<EditText
android:id="#+id/addcard_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:hint="#string/number"
android:inputType="number"
android:maxLength="16"
android:imeOptions="actionNext" // try this one
android:nextFocusDown="#+id/addcard_errormessage" // and add this one
android:scrollHorizontally="true"/>

AutoCompleteTextView is not going to the next EditText

I tried singleLine=true , imeoption=ActionNext also nextfocusdown.
but autocompleteTextView is not going to next EditText.
<AutoCompleteTextView
android:id="#+id/at_quality"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:background="#drawable/rect_border"
android:completionThreshold="1"
android:focusable="true"
android:gravity="center"
android:hint="Enter Quality"
android:singleLine="true"
android:nextFocusDown="#+id/et_design"
android:imeOptions="actionNext"
android:inputType="text"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:textColor="#color/colorPrimary"
android:textSize="16sp" />
<EditText
android:id="#+id/et_design"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:singleLine="true"
android:background="#drawable/rect_border"
android:focusable="true"
android:gravity="center"
android:hint="Design"
android:imeOptions="actionNext"
android:inputType="text"
android:paddingEnd="10dp"
android:paddingRight="10dp"
android:textColor="#color/colorPrimary"
android:textSize="16sp" />
so i want a solution in order to go to the above AutocompleteTextView to EditText on android softkey enter is clicked.

How to get EditText to not suggest text in android

I have an EditText that I need to not suggest texts as user types. But I can't seem to get that to work. Here is the code
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:hint="#string/email_hint"
android:imeActionId="#+id/login"
android:inputType="textNoSuggestions|textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:textColor="#000000" />
I solved my problem with
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="5dp"
android:hint="#string/email_hint"
android:imeActionId="#+id/login"
android:inputType="textNoSuggestions|textVisiblePassword"
android:maxLines="1"
android:singleLine="true"
android:textColor="#000000" />

Categories

Resources