动画视图
问题描述:
我有一个RecyclerView
这个布局如下所示。动画视图
当我使用view.animate().translateYBy(integer)
时,View
被指定的整数翻译。
但是,如果RecyclerView
中的内容大于屏幕上显示的内容,我无法向下滚动查看最后一个元素。我发现视图是侵入边界。如何使View
限制其底部到屏幕边框?
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent" />
</android.support.constraint.ConstraintLayout>
答
我不知道答案的正确与否,但我的建议是提row_item.xml的确切高度和宽度在RecyclerView并添加该代码将帮助您滚动视图和如预期的那样适合UI。
<HorizontalScollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- View want to scroll -->
</HorizontalScollView>
我没那么熟悉ConstraintLayout,但我想你不应该翻译的看法,但不是通过修改顶部约束 – 0X0nosugar
@ 0X0nosugar我怎么能动画,如果我改变约束滑下来改变它的高度是多少? –
我认为一个Transition([ChangeBounds](https://developer.android.com/reference/android/transition/ChangeBounds.html))应该可以工作,请参阅这个[关于transitions的博客文章](http:// www .androiddesignpatterns.com/2014/12/activity-fragment-transitions-in-android-lollipop-part1.html)作者:Alex J. Lockwood – 0X0nosugar