0

I programmatically add a button (any view) into a LinearLayout with horizontal orientation.
How to make them be automatically placed on the next line?

Here is my question but without any answer.

Community
  • 1
  • 1
Vasilii Suricov
  • 871
  • 12
  • 18
  • 1
    If you need both horizontal and vertical orientation you will either need to wrap layouts (vertically oriented LinearLayout containing two horizontally oriented LinearLayouts) or use a RelativeLayout to explicitly declare how things should be laid out. – zgc7009 Nov 21 '16 at 21:32
  • Do you mean android:layout_below="@+id/prevButtonId"? – Vasilii Suricov Nov 21 '16 at 22:16
  • You can use something like that in a relative layout if you want. Sure. I mean that's not the answer, but the idea. – zgc7009 Nov 21 '16 at 22:23

2 Answers2

0

Make it with vertical orientation instead of horizontal.

CookieMonster
  • 492
  • 6
  • 18
0

Sounds like you need a FlowLayout, there are tremendous libraries around about this (ex. https://github.com/ApmeM/android-flowlayout)

Mohammad Ersan
  • 12,304
  • 8
  • 54
  • 77