如何在GridLayout中设置MARGINS的大小 [英] How to set size of MARGINS in GridLayout

查看:136
本文介绍了如何在GridLayout中设置MARGINS的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一次使用RecyclerView将ImageButtons一次添加到GridLayout中.我的应用程序监听传入的图像和字符串以标记按钮.

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.

我想在每个按钮和文本的右侧添加一个边距,以使单词不会彼此碰到(就像下面的图片一样).

推荐答案

不,这些不是适配器的用途.

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

在XML布局文件中设置边距或填充(您可能需要填充).

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

您可以在视图的XML声明中设置android:paddingRight或android:paddingEnd.但是,如果您要确保文本不会超出某个特定点,则必须在某个特定点将其截断或允许其换行到另一行.

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.

这篇关于如何在GridLayout中设置MARGINS的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆