我有一个 GridView ,我从 2 列变成了一列。我想将此 GridView 变成一个滚动行,类似于 Google Photos 的做法。这样我就可以在顶部有一排滚动的相册,然后在顶部有个人照片。下面显示的图片是我所拥有的(带有红色工具栏的屏幕截图)与 Google 相册(我想要的,就行而言)
<GridView
android:id="@+id/grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:clipToPadding="true"
android:drawSelectorOnTop="true"
android:gravity="center"
android:horizontalSpacing="4dp"
android:listSelector="@drawable/list_selector"
android:numColumns="auto_fit"
android:paddingBottom="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="4dp"
android:scrollbars="none"
android:stretchMode="columnWidth"
android:verticalSpacing="4dp" />
最佳答案
您可以使用 Recyclerview 而不是 Gridview,它会给您结果。像这样尝试
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getApplicationContext(),3);
https://www.learn2crack.com/2016/03/grid-recyclerview-with-images-and-text.html
关于java - 将 GridView 转换为一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43859200/