Gridview无法正确滚动

时间:2015-05-14 10:05:28

标签: android android-gridview

网格视图无法在所有手机上正确滚动,以至于最后2张图像无法正确显示。请告诉我这是什么问题。我甚至尝试过填充,但它不起作用。

enter image description here

This is main layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/backg" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        
        android:src="@drawable/header1" />

    <GridView
        android:id="@+id/gridview"
        android:layout_width="wrap_content"
        android:layout_height="500dp"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:layout_above="@+id/TableLayout1"
        android:layout_gravity="bottom"
        android:layout_margin="10dp"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="4dp"
        android:background="#00FF0000"
        android:columnWidth="90dp"
        android:horizontalSpacing="10dp"
        android:numColumns="2"
        android:stretchMode="columnWidth"
        
        android:clipToPadding="false"
        android:verticalSpacing="10dp" >
    </GridView>

    <TableLayout
        android:id="@+id/TableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="bottom"
        android:stretchColumns="*" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="#505050" >

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="left"
                android:src="@drawable/bottom1" />

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:src="@drawable/bottom2" />

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:gravity="right"
                android:src="@drawable/bottom3" />
        </TableRow>
    </TableLayout>

</RelativeLayout>
This is gridview_item.xml

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="100dp">
    <com.example.myapp2.SquareImageView
        android:id="@+id/picture"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="center"
        />
    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:layout_gravity="bottom"
        android:gravity="center_horizontal"
        android:textColor="@android:color/white"
        android:background="#55000000"
        />
</FrameLayout>

1 个答案:

答案 0 :(得分:0)

我添加了android:paddingBottom =&#34; 400dp&#34;在gridview中它看起来像是在大多数手机上工作

&#13;
&#13;
<GridView
        android:id="@+id/gridview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:layout_above="@+id/TableLayout1"
        android:layout_gravity="bottom"
        android:layout_margin="10dp"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="4dp"
        android:background="#00FF0000"
        android:columnWidth="90dp"
        android:horizontalSpacing="10dp"
        android:numColumns="2"
        android:stretchMode="columnWidth"
        android:paddingBottom="400dp"
        android:clipToPadding="false"
        android:verticalSpacing="10dp" >
    </GridView>
&#13;
&#13;
&#13;