Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何让GridView在Android中显示所有组件(无需滚动)_Android_Gridview - Fatal编程技术网

如何让GridView在Android中显示所有组件(无需滚动)

如何让GridView在Android中显示所有组件(无需滚动),android,gridview,Android,Gridview,这是我的xml文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="@dimen/small_mar

这是我的xml文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="@dimen/small_margin"
    android:layout_marginRight="@dimen/small_margin"
    android:background="@android:color/transparent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none"
        android:background="@android:color/transparent"
        android:id="@+id/nested_scrollview"

        >

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

                </RadioGroup>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_marginBottom="@dimen/medium_margin"
                android:background="@drawable/button_layout_progress_fragment">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:layout_marginTop="@dimen/medium_margin"
                    android:layout_marginRight="@dimen/small_margin"
                    android:layout_marginLeft="@dimen/small_margin"
                    android:layout_marginBottom="@dimen/small_margin">
                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:textAppearance="?android:textAppearanceMedium"
                        android:text="Time spent:"
                        android:textStyle="bold"
                        android:textColor="@android:color/black"
                        android:layout_marginRight="@dimen/small_margin"/>
                    <TextView
                        android:textColor="@android:color/black"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:textAppearance="?android:textAppearanceMedium"
                        android:text="2hrs 37 mins" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:layout_marginRight="@dimen/small_margin"
                    android:layout_marginLeft="@dimen/small_margin"
                    android:layout_marginBottom="@dimen/small_margin"
                    >
                    <TextView
                        android:textColor="@android:color/black"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:textAppearance="?android:textAppearanceMedium"
                        android:text="New words learnt:"
                        android:textStyle="bold"
                        android:layout_marginRight="@dimen/small_margin"/>
                    <TextView
                        android:textColor="@android:color/black"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:textAppearance="?android:textAppearanceMedium"
                        android:text="259 words"/>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:layout_marginRight="@dimen/small_margin"
                    android:layout_marginLeft="@dimen/small_margin"
                    android:layout_marginBottom="@dimen/medium_margin"
                    >
                    <TextView
                        android:textColor="@android:color/black"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:textAppearance="?android:textAppearanceMedium"
                        android:text="Word roots learnt:"
                        android:textStyle="bold"
                        android:layout_marginRight="@dimen/small_margin"/>
                    <TextView
                        android:textColor="@android:color/black"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:textAppearance="?android:textAppearanceMedium"
                        android:text="37 words"/>
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:background="@drawable/button_layout_progress_fragment"
                >
                <GridView
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_height="200dp"
                    android:layout_width="match_parent"
                    android:id="@+id/gvBadges"

                    android:numColumns="3"

                    android:horizontalSpacing="10dp"
                    android:verticalSpacing="10dp"
                    android:gravity="center"
                    android:stretchMode="columnWidth"
                    >
                </GridView>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

我在里面使用了一个scrollview封面gridview。我只想使用scrollview向下滚动屏幕,所以gridview将显示其中的所有项目。 我怎样才能做到?提前谢谢你

使用

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

而不是

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none"
        android:background="@android:color/transparent"
        android:id="@+id/nested_scrollview">


它不起作用:(我想你的gridview是问题所在,删除它看看会发生什么,但我必须使用gridview。它不能被删除。你确定gridview会造成问题吗?我不明白。如果我不使用gridview,那么这个屏幕上只有一个滚动条。我的问题出现是因为我有两个滚动条,一个用于gridview,一个用于scrollview,我想只使用scrollview的滚动,那么gridview的滚动就不是必需的了!