相关疑难解决方法(0)

Android:项目之间的GridLayout间距

我有一个充满按钮的网格布局,现在我希望按钮彼此更远,我应该写什么代码?我试图搜索它,但只找到了GridView的解决方案,而不是GridLayout.

android android-gridlayout

17
推荐指数
2
解决办法
3万
查看次数

GridLayout(不是GridView) - 单元格之间的空格

我正在使用GridLayout(支持)ImageView在我的应用程序中显示s.有3列5行.问题是细胞在GridLayout它们之间自动获得一些空间.我没有为细胞设置任何填充或边距.请参考下图.动态添加所有单元格,以下是添加这些单元格的方法.

获得屏幕宽度和高度:

Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
screenWidth = size.x;
screenHeight = size.y;
rowHeight = (int) (screenHeight * 0.2);
Run Code Online (Sandbox Code Playgroud)

将视图添加到GridLayout:

    GridLayout.LayoutParams params = new GridLayout.LayoutParams(
            getSpec(rowColumn[0]), getSpec(rowColumn[1]));

    params.height = rowHeight;

    if (rowColumn[1].equalsIgnoreCase("col_full")) {
        params.width = (int) (screenWidth);
    } else if (rowColumn[1].equalsIgnoreCase("col_two_part")) {
        params.width = (int) (screenWidth * 0.6);
    } else {
        params.width = (int) (screenWidth * 0.3);
    }

    ImageButton image = (ImageButton) imageHashMap
            .get(reOrderedButtonsListCopy.get(i));
    image.setLayoutParams(params);

    gridLayout.addView(image, params);
Run Code Online (Sandbox Code Playgroud)

XML布局:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.xx.xxx"
    android:id="@+id/scrollView1"
    android:layout_width="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android android-gridlayout

11
推荐指数
1
解决办法
3万
查看次数

标签 统计

android ×2

android-gridlayout ×2