我在NestedScrollView
内有ConstraintLayout
。 ConstraintLayout
包含一堆视图,但最后的View
可以有一个动态高度来填充底部空间(如果有),但如果没有足够的空间,它也需要是最小高度。查看minHeight in ConstraintLayout
为了讨论起见,下面是一个例子。
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout_height="match_parent">
<View
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintHeight_min="1500dp"
android:background="@color/red"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
正如你所看到的,我已经把ConstraintLayout
版本,但它不起作用。很明显,这些值非常大,但这只是为了测试。
如果我不设置在NestedScrollView
然后ConstraintLayout
fillViewport="true"
具有0的高度。当我设置fillViewport
,该ConstraintLayout
不滚动,但只是充满屏幕。
如何设置视图使其扩大到ConstraintLayout
的底部,该视口应与视口一样大,但如果我的视图不是minHeight
那么我们允许滚动?
我正在使用ConstraintLayout
库的1.0.2
版本。
我期望看到的是一直到父母的底部,但如果该大小小于1500dp
那么视图会滚动。
我输入了1500dp,就像android:layout_height="1500dp"
那样,并且视图会相应地滚动。
更新1
好像是有一次我把一个FragmentViewPager
内的布局。 app:layout_constraintHeight_min
属性不受尊重,它只匹配视口的高度。
我也试着把NestedScrollView
从片段中拿出来,把ViewPager
放在里面,但是再次没有成功。
您正在使用哪个版本的'ConstraintLayout'? – Cheticamp