Android ListView没有';t在相对和线性布局下工作
我在滚动线性布局(内部相对)中的listview时遇到问题。 (在其他活动滚动作品中,但我只有一个线性布局) 我可以按如下方式使用它吗?或者我需要减少版面数量 我试图手动设置滚动功能Android ListView没有';t在相对和线性布局下工作,android,android-activity,layout,Android,Android Activity,Layout,我在滚动线性布局(内部相对)中的listview时遇到问题。 (在其他活动滚动作品中,但我只有一个线性布局) 我可以按如下方式使用它吗?或者我需要减少版面数量 我试图手动设置滚动功能 <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
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="match_parent"
tools:context=".post_watch"
android:background="#979797">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/PopupOverlay"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:nestedScrollingEnabled="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/commenter"
android:layout_below="@+id/viewer"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:nestedScrollingEnabled="true"
android:scrollbarAlwaysDrawVerticalTrack="true">
<ListView
android:id="@+id/fview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:scrollbarSize="3dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:scrollingCache="true"
android:smoothScrollbar="true"
android:nestedScrollingEnabled="true"
android:scrollbarAlwaysDrawVerticalTrack="true"/>
</LinearLayout>
</RelativeLayout>
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
找到解决方案(将协调器更改为抽屉布局):
```
添加“`android:scrollY=“@dimen/activity\u vertical\u margin”和android:scrollbarAlwaysDrawVerticalTrack=“true”``后,我可以使用scroll一次。。。。然后,滚动被禁用。
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
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="match_parent"
tools:context=".post_watch"
android:background="#979797">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/PopupOverlay"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:nestedScrollingEnabled="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/commenter"
android:layout_below="@+id/viewer"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:nestedScrollingEnabled="true"
android:scrollbarAlwaysDrawVerticalTrack="true">
<ListView
android:id="@+id/fview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:scrollbarSize="3dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
android:scrollingCache="true"
android:smoothScrollbar="true"
android:nestedScrollingEnabled="true"
android:scrollbarAlwaysDrawVerticalTrack="true"/>
</LinearLayout>
</RelativeLayout>
</com.google.android.material.appbar.AppBarLayout>
</androidx.drawerlayout.widget.DrawerLayout>```