Hallo Ich entwickle kleine Android-Anwendung, in der ich einfache Gridview mit einigen Elementen anzeigen möchte.Sie funktioniert ordnungsgemäß. Das einzige Problem ist, dass es immer nur zwei Spalten anzeigt, obwohl es Platz gibt. Sein Bildschirm wird gleichmäßig in zwei Spalten geteilt und zeigt nur zwei Elemente an. Wenn ich die Anzahl der Spalten als Zahl einstelle, d. H. Nicht automatisch anpassen, wird sie korrekt angezeigt. Mein Code sieht so aus:Android Gridview android: numColumns = "auto_fit" immer nur zwei Spalten erstellen
<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>
und mein Gitterelement wie folgt aussieht:
<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>
Mache ich etwas falsch? Hilfe benötigen. Vielen Dank.
Ok den Punkt und seine Arbeits bekam. Vielen Dank. – nilkash
können Sie teilen, wie Sie einstellen? – Erum