【发布时间】:2026-02-10 03:30:01
【问题描述】:
我有一个 listview 和 viewpager,用于生成我的图像滑块。这两个有自己的适配器。在我的 layout.xml 中,我想将它们放入滚动视图中,但是当我这样做时,viewpager 不会使用 listview 滚动。如果您有想法,请帮帮我吗?
谢谢
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.test.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/test">
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager_news"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<ListView
android:id="@+id/news_lw"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:nestedScrollingEnabled="true">
</ListView>
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
将 NestedScrollView 与协调器布局一起使用
标签: android listview android-viewpager scrollview