1

写真のように同じグリッド レイアウトを持つアプリを構築することを考えていますが、どのレイアウトを使用すればよいかわかりません。

GridView、またはそのようなものですか?

グーグルプラス

4

3 に答える 3

2

StaggeredGridView を使用して可能です。github の以下のリポジトリをチェックしてください

https://github.com/maurycyw/StaggeredGridView

https://github.com/chrisjenx/StaggeredGridView/tree/master/demo

于 2013-01-16T16:28:12.457 に答える
1

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 もおそらく機能するでしょうが、私自身、いまいましいことを機能させることができませんでした。

于 2013-01-16T19:31:31.677 に答える
0

GridLayout彼らが何を使用しているのか正確にはわかりませんが、 aまたは aを使用して同じ効果を得ることができますListView

于 2013-01-11T18:07:54.977 に答える