UITextView on Android (EditText?)

I am looking for the equivalent of a UITextView (known from iOS Dev) on Android.

In particular, I would like the user to be able to select one of several TextViews, be able to enter text (including line breaks), and then cancel the TextView again.

I am aware of the EditText element, but it looks like I cannot set the Finish and Enter buttons on the keyboard, and I would really like for me not to have a button next to my TextField.

Thank you very much!

+5
source share
5 answers

from the xml section, go to your edittexts, set the text for the 'inputtype' attribute. Thus, when your keyboard is open, the "done" or "next" button will appear if there are more edittexts.

+5
source

In Android, unlike iOS, the user always has a back button available to close the keyboard (if that means you “deselect the text”). This is why the "done" button is not needed if you want to exit EditText editing. Alternatively, you can use

editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { } }); 

to know when the text being edited is not focused by the user by clicking on another view of the user interface.

I am afraid that it is impossible to break lines on the keyboard and the "next" keyboard at the same time. My suggestion for this is perhaps to create a button next to edittext when the focus in this view works like a "done" or "next" button.

Hope this helps!

+3
source

I think there is no way to do this. You can choose only one imeOption . You can allow multiple lines and imeOption actionDone . When you enter a lot of new lines, it will appear, but you will not get a chance to make a broken line. Here are some links to the topic:

How to use more than one imeOptions in android

Android EditText: done instead of typing or Word Wrap instead of Multi Line

Text fields (you can see that you can only select one option. Read "Specifying Keyboard Actions")

I know this is not a satisfactory einser, but I think it helps to understand why this is not possible.

+1
source

I had a similar problem when I was developing an Android application for the client. They asked me to implement Textview to match iOS behavior. Android does not have this behavior, but we can fool the user and enable iOS behavior on Android. Here is what I did.

  • Create a Framelayout for each field, and inside Framelayout, put a Textview on the Edit text and hide the default Edit text.
  • Listen to onclick () for text viewing.
  • When the user clicks the text box, hides the Textview and displays the text "Edit Text" and opens the keyboard (you need to do this through code that will not pop up immediately). After the user has entered his text, find the "Finish" button, press on the keyboard and open the keyboard action, and also press the "Back" button. When any of these events occurs, hide the “Edit” text and show “Text View” by filling out the text box with text data.

Hope this helps.

+1
source

You can try this hope that it will work for you. If it doesn’t work, answer me, I will try to do my best.

For the following edit text: android:imeOptions="actionNext"

 <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:textColorHint="#d4d0d0" android:layout_height="wrap_content"> <AutoCompleteTextView android:id="@+id/userName" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint=" Your Name " android:theme="@style/EditScreenTextInputLayoutStyle" android:textColor="#ffff" android:imeOptions="actionNext" android:textColorHint="#ffff" android:inputType="textPersonName" android:textSize="15sp" android:maxLines="1" android:singleLine="true" /> </android.support.design.widget.TextInputLayout> 
0
source

Source: https://habr.com/ru/post/1258419/


All Articles