How to set size of MARGINS in GridLayout

拥有回忆 提交于 2019-12-23 06:27:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!