【发布时间】:2016-09-09 09:56:33
【问题描述】:
我用片段实现 NonSwipeableViewPager 有像这样的 NestedScrollView,我期望滚动视图可以向上滚动并显示 2 个文本视图:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/header" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_up" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text 1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text 2" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
但无法滚动,我尝试了很多方法但仍然没有得到任何解决方案
【问题讨论】:
-
ScrollView 需要他们孩子的身高是 wrap_content
-
@TimCastelijns 所以我们没有办法使用 match_parent 高度,不是吗?
-
这就是滚动视图的工作原理,您可以将滚动视图设置为匹配父视图,而不是滚动视图的子视图,需要包装内容
标签: android android-nestedscrollview