【发布时间】:2020-03-25 04:30:38
【问题描述】:
我的活动中有 ViewPager 和网格视图。当我在屏幕上的任何位置滚动时,ViewPager 和网格视图应该同时滚动。这是我的 ss :image。现在只有少数图像显示在网格视图我有 63 张图片,但在网格中只显示了 9 张..2)ss main
xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#fff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginBottom="8dp"/>
<LinearLayout
android:id="@+id/SliderDots"
android:layout_below="@+id/viewPager"
android:orientation="horizontal"
android:gravity="center_vertical|center_horizontal"
android:layout_width="match_parent"
android:layout_height="15dp"/>
<GridView
android:id="@+id/mGridView"
android:layout_width="match_parent"
android:layout_height="554dp"
android:background="#ffffff"
android:columnWidth="172dp"
android:gravity="center"
android:horizontalSpacing="5dp"
android:numColumns="auto_fit"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:paddingRight="5dp"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
【问题讨论】:
-
您不想在 ViewPager 中使用 GridView 吗?而不是下
-
不,我想要它们分开......并同时垂直滚动......看看我添加的截图链接
-
嘿,我编辑了我的代码..现在网格中只显示了几张图像,但滚动工作......但我希望显示图像
-
但我希望所有图像都显示在网格中
-
那你为什么要使用 ViewPager 呢?
标签: android android-studio android-layout android-viewpager scrollview