BottomTabBar第三方依赖底部按钮

BottomTabBar第三方依赖底部按钮
//布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.bwei.my.Main2Activity">
    <com.hjm.bottomtabbar.BottomTabBar
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/bottom_tab_bar"
        >
    </com.hjm.bottomtabbar.BottomTabBar>
</RelativeLayout>

//导入依赖

compile 'com.hjm:BottomTabBar:1.1.1'
//Activity代码

package com.bwei.my;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.bwei.shouye.shouye;
import com.hjm.bottomtabbar.BottomTabBar;

public class Main2Activity extends AppCompatActivity {

    private BottomTabBar mb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        mb =(BottomTabBar)findViewById(R.id.bottom_tab_bar);
        mb.init(getSupportFragmentManager())
                .setImgSize(50,50)
                .setFontSize(8)
                .setTabPadding(4,6,10)
                .setChangeColor(Color.RED,Color.DKGRAY)
                .addTabItem("首页",R.mipmap.shouye, shouye.class)
                .addTabItem("分类",R.mipmap.icon_findall, fenlei.class)
                .addTabItem("发现",R.mipmap.icon_findall, faxian.class)
                .addTabItem("购物车",R.mipmap.icon_shoppingcart, gouwuche.class)
                .addTabItem("我的",R.mipmap.icon_mine, my.class)
                .isShowDivider(false)
                .setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() {
                    @Override
                    public void onTabChange(int position, String name) {

                    }
                });
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在uniapp中跳转到底部tabBar可以使用uni.switchTab()方法。首先,在pages.json文件中添加tabBar配置,配置每个tab对应的页面路径和图标等信息。然后,在代码中使用uni.switchTab()方法进行跳转,传入对应的页面路径即可实现跳转到底部tabBar的功能。 在给定的引用中,pages.json文件中的配置如下: ```json "pages": [ { "path": "pages/index/index", "style": { "navigationBarTitleText": "分享" } }, { "path": "pages/read/read", "style": { "navigationBarTitleText": "阅读" } }, { "path": "pages/mine/mine", "style": { "navigationBarTitleText": "我的" } } ], "tabBar": { "color": "#7A7E83", "selectedColor": "#3cc51f", "borderStyle": "black", "backgroundColor": "#ffffff", "list": [ { "pagePath": "pages/index/index", "iconPath": "static/bottomTabBar/home2_icon.png", "selectedIconPath": "static/bottomTabBar/home1_icon.png", "text": "分享" }, { "pagePath": "pages/read/read", "iconPath": "static/bottomTabBar/readTrain2_icon.png", "selectedIconPath": "static/bottomTabBar/readTrain1_icon.png", "text": "阅读" }, { "pagePath": "pages/mine/mine", "iconPath": "static/bottomTabBar/mine2_icon.png", "selectedIconPath": "static/bottomTabBar/mine1_icon.png", "text": "我的" } ] } ``` 要跳转到底部tabBar的某个页面,可以使用uni.switchTab()方法,例如跳转到首页可以使用以下代码: ```javascript uni.switchTab({ url: '/pages/index/index' }); ``` 请问还有什么我可以帮助您的吗?

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值