欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android仿腾讯WiFi底部导航

程序员文章站 2022-04-26 15:12:01
需求就是实现一个类似腾讯WiFi的底部导航 先上一个效果图 实现思路 (1)UI布局我采用的 RelativeLayout 加FrameLayout 还有RadioGro...

需求就是实现一个类似腾讯WiFi的底部导航

先上一个效果图
Android仿腾讯WiFi底部导航

实现思路
(1)UI布局我采用的 RelativeLayout 加FrameLayout 还有RadioGroup来实现的
(2)中间那个WiFi按钮是一个属性动画效果(缩放与渐变)

XML代码




    

    

        

            

            

            

        

        

            
        
    

*适配我采用的是鸿洋大神的autolayout,所以布局是AutoRelativeLayout

按钮动画代码
【1】开启动画

    private void StartFlash() {
        AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1.0f);
        alphaAnimation.setDuration(440);

        ScaleAnimation scaleAnimation = new ScaleAnimation(
                0, 1,
                0, 1,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(440);
        AnimationSet animationSet = new AnimationSet(false);
        animationSet.addAnimation(alphaAnimation);
        animationSet.addAnimation(scaleAnimation);
        ll_btn.startAnimation(animationSet);
        xy =true;
    }

【2】关闭动画

 private void StopFlash() {
        AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0);
        alphaAnimation.setDuration(440);

        ScaleAnimation scaleAnimation = new ScaleAnimation(
                1, 0,
                1, 0,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(440);
        AnimationSet animationSet = new AnimationSet(false);
        animationSet.addAnimation(alphaAnimation);
        animationSet.addAnimation(scaleAnimation);
        ll_btn.startAnimation(animationSet);
        animationSet.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                rbWifi.setVisibility(View.VISIBLE);
                ll_btn.setVisibility(View.GONE);
                xy =false;
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

    }