何らかの理由で、私の CardView は、グリッド ビューで画像の最初の行のみを表示しています。(または私の GridView は最初の行のみを表示しています - 私にはわかりません)。
画像を動的に gridView に追加し、使用していgridAdapter.notifyDataSetChanged()
ます。おそらくこれが CardView の高さが適応しない理由でしょうか? Android:layout_height="500dp" を CardView に追加すると、すべての画像が表示されます。
(高さをハードコーディングする以外に) すべての画像を表示できるように、CardView にコンテンツをラップさせる方法はありますか?
写真の行数は動的であるため、高さをハードコードすることはできません。
実際には 2 行の画像がある場合でも、1 行の画像しか表示されない
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="2dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/m_photos" />
<GridView
android:id="@+id/m_grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:clickable="true"
android:columnWidth="90dp"
android:drawSelectorOnTop="true"
android:focusable="true"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="none"
android:verticalSpacing="2dp" />
</LinearLayout>
</android.support.v7.widget.CardView>