【问题标题】:Bind ScrollBar of GridView to end of screen将 GridView 的 ScrollBar 绑定到屏幕末尾
【发布时间】:2015-04-14 00:07:29
【问题描述】:

如何更改ScrollBarGridView 中的位置?

在我的情况下它绑定到项目位置:

最后一项和ScrollBar 之间有空闲空间。这个滚动与项目重叠。我需要为项目保存paddingRight,而不是为ScrollBar

我该怎么做?

gridview .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 >

gridview 项目 .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>

编辑:


当前(参见 ScrollBar 与图像重叠):

预期:

【问题讨论】:

  • 能否通过图片发布当前和预期的结果。
  • @Rod_Algonquin,请检查我的编辑。我只想在项目右侧制作适当的填充/边距,但不知道如何

标签: android gridview


【解决方案1】:

自己解决:

删除了布局中的填充,因此 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
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-04
    • 1970-01-01
    • 1970-01-01
    • 2021-08-02
    • 2019-11-19
    • 2021-06-05
    • 2022-01-10
    • 1970-01-01
    相关资源
    最近更新 更多