您好我正在开发小型Android应用程序,我想显示简单的gridview与一些elements.Its正常工作。唯一的问题是,即使有空间,它总是只显示两列。它将屏幕平分为2列,只显示两个元素。如果我将列数设置为数字,即不是auto_fit,则显示正确。我的代码如下所示:Android GridView的android:numColumns =“auto_fit”总是只创建两列

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

>

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">

和我的格子元素的样子:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

tools:context="com.example.androidcardlayout.MainActivity" >

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">

android:id="@+id/cardMianRlt"

android:layout_width="100dp"

android:layout_height="150dp"

>

难道我做错了什么?需要一些帮助。谢谢。

2014-12-08

nilkash

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐