我在创建适当的android gridview布局时遇到问题

时间:2014-06-18 15:42:09

标签: android gridview layout scrollview

我正在尝试创建一个简单的gridview布局,但我并没有成功完成它。我已经创建了下面的那个,但我希望能够将整个屏幕与" Test Header"一起滚动。并且还可以显示所有项目,而不是在屏幕中间切割它们,如下图所示。

http://s23.postimg.org/sz7jca9m3/Screenshot_2014_06_18_17_21_57.png

我正在使用的布局如下。

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

    <ScrollView
        android:id="@+id/home_scrollview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Test Header"
                android:textSize="20sp" />

            <it.gmariotti.cardslib.library.view.CardGridView
                android:id="@+id/myGrid"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:columnWidth="160dp"
                android:gravity="center"
                android:horizontalSpacing="2dp"
                android:numColumns="auto_fit"
                card:list_card_layout_resourceID="@layout/grid_gplay" >
            </it.gmariotti.cardslib.library.view.CardGridView>

        </LinearLayout>
    </ScrollView>

</LinearLayout>

我很感激这里的任何想法或帮助。

提前谢谢

1 个答案:

答案 0 :(得分:-1)

删除

您的gridview将正常运行.. <ScrollView android:id="@+id/home_scrollview" android:layout_width="match_parent" android:layout_height="match_parent" >