Umano Android的SlidingUpPanel - 动画 [英] Umano Android SlidingUpPanel - animation

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

问题描述

我使用下列项目: https://github.com/umano/AndroidSlidingUpPanel

它的工作原理非常漂亮,到目前为止,但我有一个问题:我想隐藏的滑动面板,直到我preSS一个按钮,然后在面板应在消退,与动画;当按钮为pressed,但没有动画当前显示的面板,我不知道如何实现说的动画。

It works very nicely so far, but I have one issue: I want to hide the slidable panel until I press a button, then the panel should be faded in, with an animation; currently the panel is shown when the button is pressed, but without an animation, and I don't know how to implement said animation.

任何想法将非常欢迎!

推荐答案

我知道这是连续4个月以来,你问过,但我还是决定反正张贴解答(所以别人也许可以从中受益)。

I know it's been 4 months since you asked, but I decided to post an answer anyways (so someone else can maybe benefit from it).

在可滑动面板衰落是比较容易的。你只需要在开始的布局,重新$ P的 AlphaAnimation $ psents可滑动面板。你可能会需要通过添加禁用面板阴影

Fading in the slideable panel is relatively easy. You just need to start an AlphaAnimation on layout that represents the slideable panel. You will probably need to disable the panel shadow by adding

sothree:shadowHeight="0dp"

要在你的XML的主要布局。

to the major layout in your xml.

更有趣的是,当你想扩大从屏幕底部的滑动面板(如果面板底部锚定)。在这种情况下,你可以使用下面的code:

The more interesting thing is when you want to expand the slideable panel from the bottom of the screen (if panel is anchored at the bottom). In this case, you can use the following code:

import android.view.animation.Animation;
import android.view.animation.Transformation;

import com.sothree.slidinguppanel.SlidingUpPanelLayout;

public class SlidingUpPanelResizeAnimation extends Animation {

    private SlidingUpPanelLayout mLayout;

    private float mTo;
    private float mFrom = 0;

    public SlidingUpPanelResizeAnimation(SlidingUpPanelLayout layout, float to, int duration) {
        mLayout = layout;
        mTo = to;

        setDuration(duration);
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        float dimension = (mTo - mFrom) * interpolatedTime + mFrom;

        mLayout.setPanelHeight((int) dimension);

        mLayout.requestLayout();
    }
}

和通过启动动画:

SlidingUpPanelLayout slidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.id_of_your_major_layout);

int slideablePanelHeight = 100;
int animationDuration = 800;

SlidingUpPanelResizeAnimation animation = new SlidingUpPanelResizeAnimation(slidingUpPanelLayout, slideablePanelHeight, animationDuration);
mSlidingLayout.startAnimation(animation);

这篇关于Umano Android的SlidingUpPanel - 动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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