Can someone please point me in the right direction how to do those bubbles or labels in the EditText something like those you see when you want to compose something in Stream for Google+ when you add a circle or contact? The Rectangle is an auto complete edittext.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You can do this by creating a subclass of
android.text.style.DynamicDrawableSpan
.ImageSpan
is an example of this: it replaces a span (range) of text with an image.This example will put an a star in an edit field, replacing the text "test". Create an EditText in your layout with the id of "text" and put this in
onCreate()
(or wherever):I didn't see any classes that looked like they could wrap normal text in a drawable, but that could be pretty easily solved by overriding the
getDrawable()
method and rendering the text yourself.I solved this HERE Contact Bubble EditText
I think it use setCompoundDrawables() method to insert that picture inside edit text
I built TokenAutoComplete on github to solve a similar problem and it should work for you as well. Here's a basic implementation of a demo app:
Layout code for contact_token (you can use any kind of layout here or could throw an ImageView in if you want images in the token)
Token backgound drawable
Person object code
Sample activity
Layout code
To set the circle icon in the left of the
EditText
you can change theleftDrawable
.You can do it on the layout xml file
android:drawableRight="@drawable/search_icon"
or programmatically using thesetCompoundDrawablesWithIntrinsicBounds
function.If you also want to give the bubble style, you must change the backgroud drawable by a 9-patch that have the style. here you have a tutorial for a 9-patch bubble for google maps.
Hope it helped! :)
If you mean the hints, you can add the simply with:
This will put the grey label in the EditText when it is empty.