Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android UI control like tag control

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 ?

like image 789
John Donvan Avatar asked Oct 17 '25 19:10

John Donvan


2 Answers

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>

like image 164
M.Sameer Avatar answered Oct 20 '25 08:10

M.Sameer


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.

like image 39
Rammohan Raja Avatar answered Oct 20 '25 09:10

Rammohan Raja