Aligning Dynamic Buttons In Gridlayout
I am trying to align dynamic buttons in Grid layout. Problem: However, if text is more than one line the formation of buttons in row is not as needed. String item[] = new St
Solution 1:
I recommend to use an Adapter and then customize however you want check out this example http://androidexample.com/Custom_Grid_Layout_-_Android_Example/index.php?view=article_discription&aid=76
Solution 2:
I think using a recyclerView with GridLayoutManager should help you out.
This post https://inducesmile.com/android/android-gridlayoutmanager-with-recyclerview-in-material-design/ should help you out.
Solution 3:
You only need to apply a layout_gravity as the default seems to be to align the text to be the same height (this is why it only happens with the item 3 with two lines).
GridLayout.LayoutParamsparam=newGridLayout.LayoutParams();
param.height = GridLayout.LayoutParams.WRAP_CONTENT;
param.width = GridLayout.LayoutParams.WRAP_CONTENT;
param.setGravity(Gravity.BOTTOM);
Post a Comment for "Aligning Dynamic Buttons In Gridlayout"