# YTabbarLayout **Repository Path**: lhgllj/YTabbarLayout ## Basic Information - **Project Name**: YTabbarLayout - **Description**: No description available - **Primary Language**: Android - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-06-16 - **Last Updated**: 2025-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # YTabbarLayout 底部菜单导航(tabbar+badge+fragment) ![输入图片说明](https://gitee.com/lhgllj/YTabbarLayout/blob/master/shot/tabbar_shot1.png "在这里输入图片标题") ![Alt text](https://gitee.com/lhgllj/YTabbarLayout/blob/master/shot/tabbar_shot1.png) ![Alt text](https://gitee.com/lhgllj/YTabbarLayout/blob/master/shot/tabbar_shot2.png) ![Alt text](https://gitee.com/lhgllj/YTabbarLayout/blob/master/shot/tabbar_shot3.png) ![Alt text](https://gitee.com/lhgllj/YTabbarLayout/blob/master/shot/tabbar_shot4.png) # 1. 在project的build.gradle添加如下代码(如下图) ```Java allprojects { repositories { maven { url "https://jitpack.io" } } } ``` # 2. 在build.gradle添加依赖 ```Java implementation 'com.github.yanyanmm:YTabbarLayout:v1.1.0' ``` # 3. 在xml中,加入以下代码: ```xml ``` # 4. 在代码中添加如下代码: ```Java YTabbarLayout tabbarLayout = findViewById(R.id.tabbarLayout); List tabbarItems = new ArrayList(); tabbarItems.add(YTabbarItem.createItem(R.mipmap.menu_home, R.mipmap.menu_home_selected, "首页",new HomeFragment())); tabbarItems.add(YTabbarItem.createItem(R.mipmap.menu_circle, R.mipmap.menu_circle_selected, "班级圈",new CircleFragment())); tabbarItems.add(YTabbarItem.createCenterItem(R.mipmap.menu_center)); tabbarItems.add(YTabbarItem.createItem(R.mipmap.menu_msg, R.mipmap.menu_msg_selected, "消息",new MsgFragment())); tabbarItems.add(YTabbarItem.createItem(R.mipmap.menu_my, R.mipmap.menu_my_selected, "我的",new MyFragment())); tabbarLayout.setTabbarItems(tabbarItems, getSupportFragmentManager()); ``` # 5. 自定义属性设置: ```xml ``` # 6. YBadgeView设置: ```Java YBadgeView badgeView0 = new YBadgeView(this); badgeView0.setTargetView(tabbarLayout.getTabbarItemViews().get(0).getImageView()); YBadgeView badgeView1 = new YBadgeView(this); badgeView1.setTargetView(tabbarLayout.getTabbarItemViews().get(1).getImageView()); badgeView1.setBadgeCount(8); YBadgeView badgeView2 = new YBadgeView(this); badgeView2.setTargetView(tabbarLayout.getTabbarItemViews().get(2).getImageView()); badgeView2.setBadgeCount(105); YBadgeView badgeView3 = new YBadgeView(this); badgeView3.setTargetView(tabbarLayout.getTabbarItemViews().get(3).getImageView()); badgeView3.setBadgeText("NEW"); ```