Android仿腾讯WiFi底部导航
程序员文章站
2022-09-30 14:18:43
需求就是实现一个类似腾讯WiFi的底部导航
先上一个效果图
实现思路
(1)UI布局我采用的 RelativeLayout 加FrameLayout 还有RadioGro...
需求就是实现一个类似腾讯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) { } }); }