带动画的下滑和上滑布局 [英] Slidedown and slideup layout with animation

查看:26
本文介绍了带动画的下滑和上滑布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我按下按钮时,如何使用slideUp在中心显示布局,然后再次按下以隐藏......在ANDROID中的slideDown

how can I display a layout in the center with slideUp when I press the button, and press again to hide ... slideDown in ANDROID

帮我解决这个问题,谢谢

help me with that, thnkss

推荐答案

在res/anim文件夹下创建两个动画xml

Create two animation xml under res/anim folder

slide_down.xml

slide_down.xml

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

<translate
    android:duration="1000"
    android:fromYDelta="0"
    android:toYDelta="100%" />
</set>

slide_up.xml

slide_up.xml

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

<translate
    android:duration="1000"
    android:fromYDelta="100%"
    android:toYDelta="0" />
</set>

加载动画如下代码并根据您的要求在需要时启动动画

Load animation Like bellow Code and start animation when you want According to your Requirement

//Load animation 
Animation slide_down = AnimationUtils.loadAnimation(getApplicationContext(),
            R.anim.slide_down);

Animation slide_up = AnimationUtils.loadAnimation(getApplicationContext(),
            R.anim.slide_up);

// Start animation
linear_layout.startAnimation(slide_down); 

这篇关于带动画的下滑和上滑布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆