• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >Android > 仿Android印象笔记底部导航栏

仿Android印象笔记底部导航栏

作者:网友 字体:[增加 减小] 来源:互联网 时间:2017-05-26

网友通过本文主要向大家介绍了android笔记,android开发笔记,android开发教程 笔记,李兴华android笔记,android读书笔记等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

仿Android印象笔记底部导航栏


最近用上了印象笔记,觉得android 版的底部导航栏挺不错的,好多应用里面都有用到,想着自己动手实现一下,不多说,先上图:
这里写图片描述 这里写图片描述
要完成这样的效果。需要自定义ViewGroup.
1、onMeasure(测量过程)
2、onLayout(布局)
3、添加动画

onMeasure(测量过程)

@Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int count = getChildCount();
        for (int i = 0; i

onLayout(布局)

 @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        View btn_main = getChildAt(getChildCount()-1);
        int left = 0;int top = 0;
        if (changed){
            for (int i = getChildCount()-1 ;i >= 0;i--){
                View viewChild  = getChildAt(i);
                int width = viewChild.getMeasuredWidth();
                int height = viewChild.getMeasuredHeight();
                left = getMeasuredWidth()- width;
                top = getMeasuredHeight() - height-distance;
                viewChild.layout(left,top,getMeasuredWidth(),getMeasuredHeight());
                distance += getDisension(100);
            }
            btn_main.setOnClickListener(this);
            changeState(currentState);
        }
    }

添加动画

public void openTranslateAnimation(View view){
        distance = 0;
        RotateAnimation animation = new RotateAnimation(0f,45f, Animation.RELATIVE_TO_SELF,
                0.5f,Animation.RELATIVE_TO_SELF,0.5f);
        animation.setDuration(500);
        animation.setFillAfter(true);
        view.startAnimation(animation);
        for (int i = getChildCount()-2;i>= 0; i--){
            View childView = getChildAt(i);
            view.setVisibility(View.VISIBLE);
            TranslateAnimation translate = new TranslateAnimation(
                    Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
                    Animation.RELATIVE_TO_SELF, 0.35f, Animation.RELATIVE_TO_SELF, 0);
            translate.setDuration(100);
            translate.setStartOffset(10*offset);
            translate.setFillAfter(true);
            childView.startAnimation(translate);
            offset++;
        }
    }

    public void closeTranslateAnimation(View view){
        distance = 0;
        RotateAnimation animation = new RotateAnimation(45f,0, Animation.RELATIVE_TO_SELF,
                0.5f,Animation.RELATIVE_TO_SELF,0.5f);
        animation.setDuration(500);
        animation.setFillAfter(true);
        view.startAnimation(animation);
        for (int i = getChildCount()-2;i>= 0; i--){
            View childView = getChildAt(i);
            view.setVisibility(View.VISIBLE);
            TranslateAnimation translate = new TranslateAnimation(
                    Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0,
                    Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0.35f);
            translate.setDuration(100);
            translate.setStartOffset(50*offset);
            childView.startAnimation(translate);
            offset++;
        }
    }

看一下主布局:

<code class=" hljs java"><code class=" hljs xml"><com.xby.fm.view.stackmenu android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginright="20dp" android:layout_marginbottom="20dp">

        <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center">
            <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingright="10dp" android:text="首页">

            <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_menu_item">
        </imageview></textview></linearlayout>

        <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center">
            <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingright="10dp" android:text="我的音乐">

            <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_menu_item">
        </imageview></textview></linearlayout>

        <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center">
            <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingright="10dp" android:text="我的收藏">

            <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_menu_item">
        </imageview></textview></linearlayout>

        <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center">
            <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingright="10dp" android:text="个人中心">

            <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_menu_item">
        </imageview></textview></linearlayout>


            <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_main_menu">
    </imageview></com.xby.fm.view.stackmenu></code></code>

比较简单,上一下git地址:StackMenu

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • Android学习过程中的一些基础笔记,android笔记
  • 仿Android印象笔记底部导航栏

相关文章

  • 2018-01-28android SwipeRefresh下拉刷新
  • 2017-05-26Android java层音频相关的分析与理解(三)调用相关
  • 2017-05-26一个帖子学会Android开发四大组件,android四大
  • 2017-05-26Android 弱引用和软引用,android引用和软
  • 2017-05-26安卓高级组件-----图像切换器,安卓-----切换器
  • 2017-05-26首页3--界面上拉下拉的回弹效果,3--拉下
  • 2017-05-26Linux大文件已删除,但df查看已使用的空间并未减少解决
  • 2017-05-26Android开发学习——android存储,android开发存储
  • 2017-05-26认清Android Studio下的Gradle是什么
  • 2017-05-26cocos的Director、Scence、Layer(一)---摘自于官方文档,cocosscence

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 谷歌电子市场5--推荐,谷歌电子市场5--
    • 安卓的主要几大布局,安卓布局
    • clipChildren属性,clipchildren
    • android:使用gallery和imageSwitch制作可左右循环滑动的图片浏览器
    • 二维码的扫描和生成--第三方开源--ZXing,--第三方开源--zxing
    • Android Bottom Sheet详解
    • React Native控件之PullToRefreshViewAndroid下拉刷新组件讲解
    • Android 手机卫士8--删除通话记录,android8--
    • Android之侧滑导航栏,android滑导航栏
    • Android中Action Bar的使用

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有