问题
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:
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.
来源:https://stackoverflow.com/questions/37259844/how-to-set-size-of-margins-in-gridlayout