android - 半隐藏 View 的 TranslateAnimation

标签 android android-listview

在 TranslateAnimation 期间,我试图将 View 从窗口外移动到窗口内。

在建议中他们说使用 ScrollView 但即使使用它也没有任何变化。

还有其他方法吗?

编辑

这是布局:

<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);
}

当我拖动...的 ListView 项时出现问题。它只对 View 的剩余部分而不是整个 View 进行动画处理。

最佳答案

问题是当我将 View 移出 parentView 时, View 被剪切了。

解决方案是将此选项添加到 parentView:

android:clipChildren="false"

这样parentView不会切割childView,在由外到内的平移中,view还是完整的。

关于android - 半隐藏 View 的 TranslateAnimation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22564824/

相关文章:

java - 如何将包含json对象的JSON数组发送到php服务器

android - res 下定义的颜色在代码中不可用

java - 如何在ListView中显示HashMap中的项目和子项目

java - 为什么不成功 “HTTP GET request with socket ” ?

android - 在 Android ListView 中显示应用程序图标和应用程序名称

android - 带标题 View 的 ViewPager

android - 包含 Android 图像的大型 ListView

android - 如何监视和记录哪个模块在 linux 内核中持有锁?

android - 在 setOnItemClickListener 事件的 ListView 中创建 Intent

Android:在 ListView 的 onItemClick 事件中使用 AlertDialog