一个半隐藏视图的TranslateAnimation [英] TranslateAnimation of an half hidden view

查看:121
本文介绍了一个半隐藏视图的TranslateAnimation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个TranslateAnimation我试图从窗外移动视图里面。

During a TranslateAnimation I'm trying to move a view from outside the window to the inside.

在一个建议,他们说用滚动型,但即使它没有任何改变都没有。

In a suggestion they say to use a ScrollView but even with it there is no change at all.

任何其他方式来实现这一目标?

Any other way to accomplish that?

修改

这是布局:

<RelativeLayout android:layout_width="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/login_linear_layout"
    android:layout_height="wrap_content"
    android:background="@color/background_box" >

    <com.project.view.PullToRefreshListView
        android:dividerHeight="0dp"
        android:divider="#000"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:id="@+id/mainList"
        android:background="@color/background_list"
        />

    <include layout="@layout/element_contacts_button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />
</RelativeLayout>

这是动画

private void bounceBackHeader(){
    int yTranslate = state == State.REFRESHING ?
            header.getHeight() - headerContainer.getHeight() :
            -headerContainer.getHeight() - headerContainer.getTop() + getPaddingTop();

    TranslateAnimation bounceAnimation = new TranslateAnimation(
            TranslateAnimation.ABSOLUTE, 0,
            TranslateAnimation.ABSOLUTE, 0,
            TranslateAnimation.ABSOLUTE, 0,
            TranslateAnimation.ABSOLUTE, yTranslate);

    bounceAnimation.setDuration(BOUNCE_ANIMATION_DURATION);
    bounceAnimation.setFillEnabled(true);
    bounceAnimation.setFillAfter(false);
    bounceAnimation.setFillBefore(true);
    bounceAnimation.setInterpolator(new OvershootInterpolator(BOUNCE_OVERSHOOT_TENSION));
    bounceAnimation.setAnimationListener(new HeaderAnimationListener(yTranslate));

    startAnimation(bounceAnimation);
}

当我拖累的列表视图项目,会出现问题。它仅动画视图的剩余部分,​​而不是整个视图。

The problem occurs when I drag the listview items of.. it animates only the remaining part of the view and not the whole view.

推荐答案

的问题是,当我移动parentView外的视图,该视图被切断。

The problem was that when I was moving the view outside the parentView, the view is cut.

解决的办法是增加该选项的parentView:

The solution was to add this option to the parentView:

android:clipChildren="false"

在这种方式中,parentView不会切断childView,并在从外部到内部的翻译,该视图将仍然是完整的如前。

In this way, the parentView won't cut the childView, and in the translation from outside to the inside, the view will still be complete as before.

这篇关于一个半隐藏视图的TranslateAnimation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆