Android 控件的显示隐藏上下左右移动动画

Android 控件的显示隐藏上下左右移动动画,第1张

概述一、利用Android提供的左右移动工具类:AnimationUtils LinearLayout ll_first = (LinearLayout) findViewById(R.id.ll_fir

一、利用AndroID提供的左右移动工具类:AnimationUtils

    linearLayout ll_first = (linearLayout) findVIEwByID(R.ID.ll_first);    linearLayout ll_second = (linearLayout) findVIEwByID(R.ID.ll_second);    ll_first.setVisibility(VIEw.GONE);    ll_second.setVisibility(VIEw.VISIBLE);    // 向右边移出    ll_first.setAnimation(AnimationUtils.makeOutAnimation(this,true));    // 向右边移入    ll_second.setAnimation(AnimationUtils.makeInAnimation(this,true));                ll_first.setVisibility(VIEw.VISIBLE);    ll_second.setVisibility(VIEw.GONE);    // 向左边移入    ll_first.setAnimation(AnimationUtils.makeInAnimation(this,false));    // 向左边移出    ll_second.setAnimation(AnimationUtils.makeOutAnimation(this,false));

二、用TranslateAnimation添加动画

先写一个AnimationUtil工具类:这里仅提供上下移动效果

public class AnimationUtil {    private static final String TAG = AnimationUtil.class.getSimplename();    /**     * 从控件所在位置移动到控件的底部     *     * @return     */    public static TranslateAnimation movetoVIEwBottom() {        TranslateAnimation mHIDdenAction = new TranslateAnimation(Animation.relative_TO_SELF,0.0f,Animation.relative_TO_SELF,1.0f);        mHIDdenAction.setDuration(500);        return mHIDdenAction;    }    /**     * 从控件的底部移动到控件所在位置     *     * @return     */    public static TranslateAnimation movetoVIEwLocation() {        TranslateAnimation mHIDdenAction = new TranslateAnimation(Animation.relative_TO_SELF,1.0f,0.0f);        mHIDdenAction.setDuration(500);        return mHIDdenAction;    }}

隐藏的时候设置下动画就可以了

                ll_first.setVisibility(VIEw.GONE);                ll_second.setVisibility(VIEw.VISIBLE);                ll_first.setAnimation(AnimationUtil.movetoVIEwBottom());                ll_second.setAnimation(AnimationUtil.movetoVIEwLocation());

博客原文地址:http://www.cnblogs.com/liqw/p/4602876.html

总结

以上是内存溢出为你收集整理的Android 控件显示隐藏上下左右移动动画全部内容,希望文章能够帮你解决Android 控件的显示隐藏上下左右移动动画所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1119261.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存