将 GridView 的 ScrollBar 绑定到屏幕末尾

Bind ScrollBar of GridView to end of screen

如何更改 ScrollBarGridView 中的位置?

在我的案例中,它绑定到项目位置:

并且在最后一项和 ScrollBar 之间有空闲 space。并且这个卷轴与item重叠。我需要为项目保存 paddingRight 但不为 ScrollBar.

我该怎么做?

网格视图。xml:

<FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="tenkol.design.com.imbrecords.FragmentChannelsUkr"
    android:background="@color/white">

    <GridView android:id="@+id/gridView_ua"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:numColumns="3"
        android:verticalSpacing="10dp"
        android:horizontalSpacing="10dp"
        android:stretchMode="columnWidth"
        android:drawSelectorOnTop="true"
        android:gravity="center" />

</FrameLayout >

网格视图项目。xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <tenkol.design.com.imbrecords.SquaredImageView
        android:id="@+id/imageview_channelIcon"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="1dp"
        android:scaleType="center"
        />
</RelativeLayout>

编辑:


当前(见滚动条与图像重叠):

预计:

自己解决:

删除布局中的填充,以便 gridview 全屏显示:

<FrameLayout  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="tenkol.design.com.imbrecords.FragmentChannelsUkr"
android:background="@color/white">

<GridView android:id="@+id/gridView_ua"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:numColumns="3"
    android:stretchMode="columnWidth"
    android:drawSelectorOnTop="true"
    android:gravity="center" />
</FrameLayout >

并将填充添加到我的 SquaredImageView:

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
    setPadding(16,16,16,16);//Snap to width
}