Reputation: 566
I want to know how to get a control that contains list of strings arranged as in an image bellow.
you can see the strings strings added in random way based on its width
I tried to use normal textview with inside a linear or relative layout with but it didnt work. Can you pleae tell me the best practice to have a control that I pass to it a list of strings and it shows them like the image bellow ?
Upvotes: 4
Views: 2693
Reputation: 626
Google Chips can be used to displays tags. For your use-case Input chips will do the job. Read about it here. The tags/chips are completely customize-able.
The library is available for both Android and iOS so you can provide a consistent user interface for your users on both the platforms.
Upvotes: 2
Reputation: 3151
This can be done using a flow layout and toggle buttons inside it. A good flow layout is available here. And the toggle buttons will need a Selector drawable to give it the proper checked/unchecked appearance.
Here is a selector example:
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/rect_tag_checked" android:state_checked="true"></item>
<item android:drawable="@drawable/rect_tag_normal" android:state_checked="false"></item>
<item android:drawable="@drawable/rect_tag_normal"></item>
Upvotes: 3