Reputation: 4888
I want to fill the LinearLayout with buttons.
The way I want it, is by filling the top of the screen first until the end of the line then if there is no space left, go to the next line and so on, like in the below picture.
I tried this code but it fill the screen vertically
LinearLayout layout = (LinearLayout) findViewById(R.id.linear_layout_tags);
//layout.setOrientation(LinearLayout.VERTICAL);
layout.setGravity(Gravity.FILL);
Button bt1 = new Button(this);
bt1.setText("A Button");
bt1.setLayoutParams(new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT));
layout.addView(bt1);
Any help or suggestions would be appreciated.
Upvotes: 0
Views: 142
Reputation: 38223
Or you're looking for FlowLayout for Android. Some implementations are here.
https://github.com/ApmeM/android-flowlayout
https://github.com/blazsolar/FlowLayout
Upvotes: 1
Reputation: 35539
Are you looking for one of this?
MultiTextTagView
TokenAutoComplete
Android Chips
AndroidTagView
Chips Android
Upvotes: 1