-2

I am adding ImageButtons one at a time to a GridLayout using RecyclerView. My app listens for incoming images and strings to label the buttons.

I want to add a margin to the right of each button and text, so the words don't run into each other (like my image below).

  • 1
    Check this question out: [How to programmatically setting style attribute in a view](http://stackoverflow.com/questions/2016249/how-to-programmatically-setting-style-attribute-in-a-view) Hope this will answear it. – Mafick May 16 '16 at 17:49

1 Answers1

1

No, these are not the sort of things an adapter is for.

Set margin or padding (you probably want padding) inside your XML layout file.

You can set android:paddingRight or android:paddingEnd in the XML declaration of the view. But if you want to be sure the text won't go beyond a certain point you are going to have to either cut it off at a certain point or allow it to wrap to another line.

jwehrle
  • 4,414
  • 1
  • 17
  • 13