6
您好我正在开发小型Android应用程序,我想显示简单的gridview与一些elements.Its正常工作。唯一的问题是,即使有空间,它总是只显示两列。它将屏幕平分为2列,只显示两个元素。如果我将列数设置为数字,即不是auto_fit,则显示正确。我的代码如下所示:Android GridView的android:numColumns =“auto_fit”总是只创建两列
<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"
>
<GridView
android:id="@+id/gridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="5dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp">
</GridView>
</FrameLayout>
和我的格子元素的样子:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="com.example.androidcardlayout.MainActivity" >
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="100dp"
android:layout_height="150dp"
card_view:cardCornerRadius="4dp">
<RelativeLayout
android:id="@+id/cardMianRlt"
android:layout_width="100dp"
android:layout_height="150dp"
>
</RelativeLayout>
难道我做错了什么?需要一些帮助。谢谢。
确定了问题的实质和它的工作。谢谢。 – nilkash 2014-12-08 07:41:23
可以分享你如何调整? – Erum 2017-09-28 11:31:06