3

I want to know how to get a control that contains list of strings arranged as in an image bellow.

enter image description here

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 ?

John Donvan
  • 554
  • 8
  • 22

2 Answers2

3

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>

M.Sameer
  • 3,072
  • 1
  • 24
  • 37
1

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.

Rammohan Raja
  • 616
  • 1
  • 6
  • 10