tablayout + coordinatorlayout 中片段内的列表视图不滚动
listview inside fragment within tablayout + coordinatorlayout doesn't scroll
下面的 ListView 不滚动。它使用第一个布局中的 ViewPager 组件。 ViewPager 的片段是动态引入的。
ListView 的 onScroll 事件适用于加载 100 个项目,但滚动不起作用。
谁能看到sometj
我有以下 xml 布局:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@color/background_primary"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/abl_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/text_header_field"
app:theme="@style/MyMaterialTheme"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/text_header_field"
app:layout_scrollFlags="scroll|enterAlways"
android:padding="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:popupTheme="@style/CDTheme.NoActionBar.PopupOverlay"
>
<com.cashdash.views.components.TypefaceTextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:customTypeface="fonts/Montserrat-Light.otf"
android:layout_gravity="center"
android:textSize="16sp"
android:text="@string/title_activity_transaction"
android:gravity="center"
android:textColor="@color/text_title"
android:textAllCaps="true"
android:background="@color/text_header_field"
/>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="@color/background_primary_to"
app:tabBackground="@color/text_header_field"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabSelectedTextColor="@color/field_value_dark"
app:tabTextColor="@color/tab_inactive"
/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
这是片段:
<FrameLayout
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"
tools:context=".TransactionHistoryFragment"
android:background="@color/background_primary">
<ListView
android:id="@+id/lv_transaction"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
/>
</FrameLayout>
更新:
我尝试了几种方法,其中 'merge' 解决了问题。
一般是嵌套滚动的问题,解决方法大概是:
- 从父层拦截 Touch 事件并实现滚动
- 使用 xml 属性 android:nestedScrollingEnabled="true" 用于 API 21+
- 使用 ViewPager 上的页面转换作为可选解决方案
每一个都是解决方案的组成部分。
解决方法是:
- 从父层拦截 Touch 事件并实现滚动
- 对 API 21+
使用 xml 属性 android:nestedScrollingEnabled="true"
- 使用 ViewPager 上的页面转换作为可选解决方案
目前 API 20- 没有解决方案,只能以不同的方式构建整个视图。
下面的 ListView 不滚动。它使用第一个布局中的 ViewPager 组件。 ViewPager 的片段是动态引入的。 ListView 的 onScroll 事件适用于加载 100 个项目,但滚动不起作用。 谁能看到sometj
我有以下 xml 布局:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@color/background_primary"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/abl_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/text_header_field"
app:theme="@style/MyMaterialTheme"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/text_header_field"
app:layout_scrollFlags="scroll|enterAlways"
android:padding="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:popupTheme="@style/CDTheme.NoActionBar.PopupOverlay"
>
<com.cashdash.views.components.TypefaceTextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:customTypeface="fonts/Montserrat-Light.otf"
android:layout_gravity="center"
android:textSize="16sp"
android:text="@string/title_activity_transaction"
android:gravity="center"
android:textColor="@color/text_title"
android:textAllCaps="true"
android:background="@color/text_header_field"
/>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="@color/background_primary_to"
app:tabBackground="@color/text_header_field"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabSelectedTextColor="@color/field_value_dark"
app:tabTextColor="@color/tab_inactive"
/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
这是片段:
<FrameLayout
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"
tools:context=".TransactionHistoryFragment"
android:background="@color/background_primary">
<ListView
android:id="@+id/lv_transaction"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
/>
</FrameLayout>
更新:
我尝试了几种方法,其中 'merge' 解决了问题。 一般是嵌套滚动的问题,解决方法大概是:
- 从父层拦截 Touch 事件并实现滚动
- 使用 xml 属性 android:nestedScrollingEnabled="true" 用于 API 21+
- 使用 ViewPager 上的页面转换作为可选解决方案
每一个都是解决方案的组成部分。
解决方法是:
- 从父层拦截 Touch 事件并实现滚动
- 对 API 21+ 使用 xml 属性 android:nestedScrollingEnabled="true"
- 使用 ViewPager 上的页面转换作为可选解决方案
目前 API 20- 没有解决方案,只能以不同的方式构建整个视图。