2

I've seen many of questions for how to add TextView in a RelativeLayout programatically, but everybody adding it in LinearLayout with orientation vertical. Can any one suggest me or give me a link that how to add multiple TextView in RelativeLayout at right until it has space and then change the line.

I want a layout like this.. enter image description here

Onik
  • 19,396
  • 14
  • 68
  • 91
Ankit
  • 483
  • 7
  • 24
  • ankit use the layout params as you want those are margins – srinivas Jun 28 '14 at 12:44
  • i'm using layout param, but either i use RelativeLayout.RIGHT_OF or RelativeLayout.BELOW. how can i manage both togather. – Ankit Jun 28 '14 at 12:48
  • [You can calculate currently filled layout width](http://stackoverflow.com/a/12212341/1777090) and check it with device width. if layout width about to exceed or exceeded device width, then `RelativeLayout.BELOW`, else use `RelativeLayout.RIGHT_OF` – MysticMagicϡ Jun 30 '14 at 10:01
  • @PurpleDroid I've tried that code, but it returns the total width of device, not remaining width. (am i using it in correct way??). – Ankit Jun 30 '14 at 10:30
  • @Ankit try setting wrap_content for relative layout, so that it just returns used width. – MysticMagicϡ Jun 30 '14 at 10:35

2 Answers2

1

May be this works for you !

You can customize chips-edittext-library for your need. Customizing by setting background to transparent, and editable to false.

-> Or you can use any other library which is used for displaying emoticon in EditText and customize it according to your need. Like android-emoticon-edittext-spike

Arsalan Mehmood
  • 1,432
  • 1
  • 15
  • 26
0

You can use the Flow Layout library that manages the view arrangement itself.

When there is no space left the added View is moved to the next line

Apoorv
  • 13,470
  • 4
  • 27
  • 33