如何更改ScrollBar
中GridView
的位置?
它与我案件中的物品位置绑定:
以及最后一个项目与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 item .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与图像重叠):
预期:
答案 0 :(得分:0)
自己解决:
删除布局中的填充,以便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
}