Dynamic button layout in Android Layout

Asked

Viewed 132 times

0

I am developing an application that needs to have a series of custom buttons on the home screen. The amount of buttons that will be displayed will be configured. Having this information at my disposal, how can I implement their organization so that they position themselves in different ways on the screen?

My goal is to always try to center them leaving arranged in columns and rows and having at most 3 columns of buttons.

I thought about using Recyclerview but I don’t know if I can make the application this way. With your experience what you recommend me?

2 answers

0

Depending on the shape you want to position and, if it is only buttons, you can create the layout with numerous buttons, leave the visibility Invisible or Gone (depending on the situation) and go setting the visibility programmatically. As each button will have its id and you can change the feature of each programmatically.

0


I managed to find the way that solves my problem. What I did was to implement the Grid Layout which is also a list but is displayed in rows and columns that I can dynamically calculate to be able to display and position my elements in the best way.

I leave as reference the video link I used: Android Studio Tutorial - Grid View

Credits and thanks to the channel EDMT Dev by the practical, fast and very well done video on the subject.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.