了slideDown和动画的android效果基本show布局布局、效果、基本、动画

2023-09-07 15:33:17 作者:心窝里的爱人

我怎么能与效果基本show中央显示布局时我preSS按钮,preSS再次隐藏...在了slideDown ANDROID

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

帮助我与,thnkss

help me with that, thnkss

推荐答案

在创建资源2动画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>

加载动画像波纹管code,并开始在您需要根据您的要求的动画

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); 
 
精彩推荐
图片推荐