TranslateAnimation移动视图关闭屏幕-Android

时间:2015-09-13 18:08:25

标签: android

我在GridView上使用以下动画,

当活动加载slideToBottom(myGridView);

时,我隐藏它
public void slideToBottom(View view){
    TranslateAnimation animate = new TranslateAnimation(0,0,0,view.getHeight());
    animate.setDuration(500);
    animate.setFillAfter(true);
    view.startAnimation(animate);
    view.setVisibility(View.GONE);
}

我遇到的问题是,当点击一个按钮显示视图时,它只是让它在没有动画的情况下可见,当我再次点击它时会加载动画,下面滑动到顶部的代码,

public void slideToTop(View view){
    TranslateAnimation animate = new TranslateAnimation(0,0,view.getHeight(),0);
    animate.setDuration(1000);
    animate.setFillAfter(true);
    view.startAnimation(animate);
    view.setVisibility(View.VISIBLE);

}


<RelativeLayout

    android:id="@+id/container"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:clipChildren="false"
    android:clipToPadding="false"
    >
    ....some other stuff here

    <GridView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/myGridView"
        android:horizontalSpacing="2dip"
        android:numColumns="3"
        android:scrollbars="vertical"
        android:verticalSpacing="0dip"
        android:paddingTop="8dp"
         />


</RelativeLayout>

我做错了什么?

0 个答案:

没有答案