I need to add a large number of ImageButton to the page. I added ScrollView in xml so that you could scroll.

enter image description here

When I launch the application, I see it and I can scroll through it, but when I'm in development mode, it’s very hard to add new buttons because here I can not scroll the page.
There is, of course, the option to add them via TextView in xml, but this is not at all convenient.

Perhaps something tell me?

  • one
    Since you have so many buttons, it seems to me that RelativeLayout is not very suitable here. Try something like a GridView. He is already with scrolling - JustAnotherCoder
  • one
    Throw them not on the screen layout, but on the RelativeLayout container in the Component Tree window on the left (in your screenshot). You can also move them relative to each other. Also for such a layout, the root container of TableLayout or GridLayout more appropriate, but not RelativeLayout - pavlofff

1 answer 1

It is not known how many you need to add imageButton buttons. If it is relatively small, then it is possible directly in the code, but if there are still relatively many of them, or they may be increased in the future, then look towards the implementation of the RecyclerView and you can build it using the LayoutManager GridLayoutManager (arranges the elements in the grid) or LinearLayoutManager (shows items in a vertical or horizontal scrolling list). ImageButton itself can be implemented as CardView.