在 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/