現在androidアプリ開発をしていてGridViewを用いて要素を並べているのですが
GridViewのレイアウトを添付画像の様にしたいのですがどうしていいかわかりません。
やりたいこととしては、GridViewを端末の縦幅いっぱいに伸ばし、GridView内の要素のサイズを均等に20個表示させたいです。
GridViewには自前のadapterをセットしていてListItemのxmlを呼び出しています。
androidのレイアウトに関して知識が乏しいのでご教授お願いします。
MainActivity
xml
1<LinearLayout 2 android:layout_width="match_parent" 3 android:layout_height="match_parent" 4 android:orientation="vertical"> 5 <TextView 6 android:text="hogehoge" 7 android:layout_width="wrap_content" 8 android:layout_height="wrap_content" 9 android:text="4" /> 10 <GridView 11 android:id="@+id/subjectList" 12 android:layout_width="match_parent" 13 android:layout_height="match_parent" 14 android:gravity="center" 15 android:numColumns="4" 16 android:stretchMode="columnWidth" 17 /> 18</LinearLayout> 19
ListItem
xml
1<LinearLayout 2 android:layout_width="wrap_content" 3 android:layout_height="wrap_content" 4 android:orientation="vertical"> 5 6 <TextView xmlns:android="http://schemas.android.com/apk/res/android" 7 android:id="@+id/item_text" 8 android:layout_width="match_parent" 9 android:layout_height="wrap_content"></TextView> 10</LinearLayout> 11
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。