▲ Android仿腾讯WiFi底部导航

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

先上一个效果图
这里写图片描述

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

XML代码

<?xml version="1.0" encoding="utf-8"?>
<com.zhy.autolayout.AutoRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.zhy.autolayout.AutoFrameLayout
        android:id="@+id/layFrame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/rg_home"
        android:background="#288" />

    <com.zhy.autolayout.AutoFrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">

        <RadioGroup
            android:id="@+id/rg_home"
            android:layout_width="match_parent"
            android:layout_height="110px"
            android:paddingBottom="5px"
            android:layout_gravity="bottom"
            android:background="@android:color/white"
            android:orientation="horizontal"
            android:paddingTop="5px">

            <RadioButton
                android:id="@+id/rb_regulator"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:button="@null"
                android:checked="true"
                android:drawableTop="@drawable/radiobutton_home_select"
                android:gravity="center"
                android:text="管理"
                android:textColor="@drawable/main_radiobutton_text"
                android:textSize="12sp" />

            <RadioButton
                android:id="@+id/rb_wifi"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="2"
                android:button="@null"
                android:drawableTop="@drawable/radiobutton_wifi_select"
                android:gravity="center"
                android:paddingTop="6dp" />

            <RadioButton
                android:id="@+id/rb_find"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:button="@null"
                android:drawableTop="@drawable/radiobutton_home_select"
                android:gravity="center"
                android:text="发现"
                android:textColor="@drawable/main_radiobutton_text"
                android:textSize="12sp" />

        </RadioGroup>

        <com.zhy.autolayout.AutoLinearLayout
            android:id="@+id/ll_btn"
            android:layout_width="225px"
            android:layout_height="67px"
            android:layout_gravity="bottom|center_horizontal"
            android:layout_marginBottom="30dp"
            android:background="@drawable/wifi_bg"
            android:orientation="vertical"
            android:visibility="gone">

            <TextView
                android:id="@+id/tv_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="12px"
                android:text="安全连接"
                android:textColor="#FFF"
                android:textSize="14.5sp" />
        </com.zhy.autolayout.AutoLinearLayout>
    </com.zhy.autolayout.AutoFrameLayout>
</com.zhy.autolayout.AutoRelativeLayout>

*适配我采用的是鸿洋大神的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) {

            }
        });

    }

.

源码链接:https://download.csdn.net/download/macaopark/10310078

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值