写真のように同じグリッド レイアウトを持つアプリを構築することを考えていますが、どのレイアウトを使用すればよいかわかりません。
GridView、またはそのようなものですか?
写真のように同じグリッド レイアウトを持つアプリを構築することを考えていますが、どのレイアウトを使用すればよいかわかりません。
GridView、またはそのようなものですか?
StaggeredGridView を使用して可能です。github の以下のリポジトリをチェックしてください
https://github.com/maurycyw/StaggeredGridView
https://github.com/chrisjenx/StaggeredGridView/tree/master/demo
LinearLayoutでそれを行うのに十分簡単です:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Stack rows vertically -->
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<!-- First row, two items -->
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<!-- First item, 50% of width -->
<FooView android:id="@+id/foo1"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content" >
<!-- Second item, 50% of width -->
<FooView android:id="@+id/foo2"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content" >
</LinearLayout>
<!-- Next row, just one item -->
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<!-- Third item, 100% of width -->
<FooView android:id="@+id/foo2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</LinearLayout>
<!-- And so on... -->
</LinearLayout>
</ScrollView>
明らかに、「FooView」の正確な性質は、装飾的な境界線や影などと同様に、あなた次第です。実際には、これをプログラムで行いたいと思うでしょうが、この静的 xml レイアウトはあなたが求めているものを示しています。
GridLayout も機能しますが、互換性ライブラリの使用を開始しない限り、4.0 以降でのみ使用できます。LinearLayout が仕事をするので、それが私が使用するものです。RelativeLayout もおそらく機能するでしょうが、私自身、いまいましいことを機能させることができませんでした。
GridLayout
彼らが何を使用しているのか正確にはわかりませんが、 aまたは aを使用して同じ効果を得ることができますListView
。