I want to implement AutoCompleteTextView something like what Gmail app in Android does.
I am not sure how to set "To" fixed text on the left side of AutoCompleteTextView.
How is this implemented? Do I have to put TextView inside AutoCompleteTextView to show "To" label. If I do that my cursor starts from the beginning of AutoCompleteTextView and not after TextView.
How should I achieve this view
You can put a TextView to the left of the AutoCompleteTextView. Use a horizontal LinearLayout for that. You can set the border (the underline with the little ticks) on the linear layout if you want one.
My style of implementation of it is to use android:drawableLeft. Create a drawable(could be image) first which in your case "To". Then apply it in the xml declaration of your AutoCompleteTextView like this.
<AutoCompleteTextView
android:id="#+id/auto_complete_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/to_drawable_label"/>
I hope this helps. :)
you just need to create an adapter and set it to AutocomleteTextView.
Related
I am trying to make something like this example:
I want the drawable to show when I verify the user name from the server.
I am using Material Design Text Input Field & EditText. Yes, I can do it with a simple EditText and an ImageView, but I want to use the standard elements.
I have looked at the official documentation, there is a way to add the image at the Right corner using XML, but I want to add it programmatically.
Use the setEndIconDrawable method:
textInputLayout.setEndIconDrawable(R.drawable.xxxx);
textInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
or in a layout:
<com.google.android.material.textfield.TextInputLayout
app:endIconDrawable="#drawable/xxxxx"
app:endIconMode="custom"
More info in the official doc.
You need to to set your drawable programmatically like below
inputTextEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(context,R.drawable.drawableRight), null)
I want to give extra space to input texts in my edit text.
here is what I have now :
but I want to achieve this :
which property of edittext will do this (in xml) ?
or I have to do this in another way ?
Thanks in advance !
android:paddingLeft is the property you need. You can use it as android:paddingLeft="8dp"
Checkout this answer here: https://stackoverflow.com/a/4619943/1739882
Add this attribute:
android:paddingLeft="10dp"
padding usually used to give an alignment to the text inside the EditText or even Buttons
please inform me if this is what you are looking for
Is it possible to remove/change color of the delimiter in AutoCompleteTextView's popup ? In ListView I get use of the "delimiter" parameter, but I haven't found any similar in AutoCompleteTextView.
Thanks.
Use an Adapter for your AutoCompleteTextView.
Then, you can do something like this :
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
The layout can be configured by you.
A quick fix solution, for removing the divider, might be writing a custom XML to override the style for each cell (Through the SetDropDownViewResource). After that you can change the android:popupBackground property on the autocompletetextview to match it to the color of your item's background.
Is it possible to wrap a textview around a textview, where the 2nd textview would wrap to the next line under the first textview?
For example:
<This is one textview> <This is
another textview>
I have tried using android:layout_weight="1" and relative layouts, however, they dont produce this effect.
No. If you're looking to format the two bits of text differently, consider using spans within one TextView.
This will be helpful to you. You can get same effect with HTML in text view
How to display HTML in TextView?
This is impossible because the "another textview" would have a non-rectangular widget area then.
I've got a TextView that I would like to allow the user to select a range of text from within it. The TextView takes up the entire width and height of the device (minus some padding and a title at the top). In an EditText if you long-click you get a selection overlay that allows you to set your selection left and right bounds. I'd like this functionality in a TextView. I've read that in API level 9 (2.3) (http://developer.android.com/sdk/android-2.3.html) there are new text selection controls, but I'm having difficulty implementing this. I'm doing this right now:
eic = new InputConnection( bookTextView );
eic.beginBatchEdit();
But it doesn't do anything noticable. Does anyone know how to use InputConnection correctly? Thanks.
Edit: I don't necessarily need to use what I was attempting above. I ultimately want to use either a TextView or an EditText which looks and feels like a TextView and be able to select text using a dragging cursor. Then I would like to manipulate the selected text with various context menu options (or a menu that pops up above the selected text).
Here is an idea.. Add an EditText with a TextView background, Here is an example
<EditText
android:text=" This is not an editable EditText"
android:id="#+id/EditText01"
android:layout_width="wrap_content"
android:textColor = "#android:color/white"
android:editable = "false"
android:cursorVisible="false"
android:layout_height="wrap_content"
android:background = "#android:drawable/dark_header">
</EditText>
add this to your xml in the place of TextView
You can enable the TextView's Spannable storage. See Highlight Text in TextView or WebView for an example.
See also:
http://developer.android.com/reference/android/text/Spanned.html
You could display the text in a WebView and enable text selection. If you want to only use a textview/edittext, here is an answer that might help you and here is information on the Spannable class that might help you accomplish what you want.
Actually, you do not have to develop this feature by yourself. You just need to use EditText instead TextView, while you set the android:editable of EditText to false. My idea is the same as sandy's.
My code is here, hope it may help you:
https://stackoverflow.com/a/11026292/966405
After long internet surfing to find a solution, i prefered create my own class
https://github.com/orionsource/SelectableTextViewer
Goal features:
Easy to use - only one class
Support for text and Html.fromHtml
Can be in ScrollView with correct touches
Cursors can be redefined
Color of selection can be redefined
All the above solutions either too long or not working for me.
What you need is to add just textView.setTextIsSelectable(true)
in your activity or fragment or adapter.