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

标签 android android-animation

在我的 Activity 屏幕中,一半的屏幕包含一个布局。当 Activity 加载它时可见,10 秒后它会慢慢下降,最终用户将看不到它。但它下降缓慢。我该怎么做it.Please 任何人都可以帮助我。

提前致谢。

最佳答案

在您的 res\anim 文件夹中(如果不存在则创建该文件夹)创建 slide_out_down.xml 并粘贴以下内容

<?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" />

启动动画并隐藏 View 使用这个

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

关于android - 如何在android中为布局设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17340851/

相关文章:

Android开启Dialog动画监听器

android - Snackbar 动画 android

Android水平 ScrollView 像画廊

android - 如何将 15Mb 文件从 Assets 文件夹复制到 SD 卡...?

安卓棉花糖 : Galaxy Note 4 Screen Overlay Detected

android - 具有半径的 CardView 上的共享元素转换

java - ExpandableListview 上的 LayoutTransition 动画无法正常工作

android - 从 Android 应用程序将视频上​​传到 S3 AWS 会生成一个 0Kb 文件

c# - 我如何在 Unity3D 中进行触摸操作?

android - "Can' t compress a recycled bitmap”单个设备异常