如何在android中设置布局动画?

use*_*123 2 android android-animation

在我的"活动"屏幕中,屏幕的一半包含一个布局.当活动加载它时可见,10秒后它将慢慢下来,最后它将对用户不可见.但它慢慢下来.我怎么做.请发布.谁能帮我.

提前感谢.

Pla*_*ato 14

In your res\anim folder (create the folder if it's not there) create slide_out_down.xml and paste the following

<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"

android:fromYDelta="0%p"
android:toYDelta="100%p"
android:duration="@android:integer/config_longAnimTime" />
Run Code Online (Sandbox Code Playgroud)

to start the animation and hide the view use this

 private void hideView(final View view){
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.slide_out_down);
    //use this to make it longer:  animation.setDuration(1000);
    animation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {}

        @Override
        public void onAnimationRepeat(Animation animation) {}

        @Override
        public void onAnimationEnd(Animation animation) {
             view.setVisibility(View.GONE);
        }
    });

    view.startAnimation(animation);
}
Run Code Online (Sandbox Code Playgroud)