简体   繁体   English

动画视图

[英]Animating a View

I have a RecyclerView with this layout shown below. 我有一个RecyclerView ,其布局如下所示。

When I use view.animate().translateYBy(integer) , the View is translated by the integer specified. 当我使用view.animate().translateYBy(integer)View由指定的整数转换。

However, if the content in the RecyclerView is greater than what is shown on screen I can't scroll down to see the last element. 但是,如果RecyclerView的内容大于屏幕上显示的内容,则无法向下滚动以查看最后一个元素。 I figured out that the view is trespassing the borders. 我发现该视图越过边界。

How can I make the View limit its bottom to the screen borders? 如何使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>

I don't know the answer is correct or not, But my suggestion is to mention the exact height and width of the row_item.xml in your RecyclerView and add this code will help you scrolling of the view and fit the UI as expected. 我不知道答案是否正确,但我的建议是在RecyclerView中提及row_item.xml的确切高度和宽度,并添加此代码将帮助您滚动视图并按预期适合UI。

<HorizontalScollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<!-- View want to scroll -->
</HorizontalScollView>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM