GithubHelp home page GithubHelp logo

shengshiweijun / bottombarlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liuhao2018/bottombarlayout

0.0 2.0 0.0 132 KB

Android BottomBar封装底部TAB导航栏,支持显示红点和数字提醒。

Java 100.00%

bottombarlayout's Introduction

BottomBarLayout

使用:

XML:

	<com.example.liuhao.bottombar.BottomBarLayout
        android:id="@+id/bottom_nav"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="#FFFFFF"
        android:layout_alignParentBottom="true"/>

Activity:

init:

private BottomBarLayout bottomBarLayout;
private List<TabEntity> tabEntityList;
private String[] tabText = {"tab0","tab1","tab2","tab3"};

private int[] normalIcon = {R.mipmap.home,R.mipmap.play,R.mipmap.buy,R.mipmap.mine};
private int[] selectIcon = {R.mipmap.home1,R.mipmap.play1,R.mipmap.buy1,R.mipmap.mine1};
private int normalTextColor = Color.parseColor("#999999");

private int selectTextColor = Color.parseColor("#fa6e51");
bottomBarLayout = (BottomBarLayout) findViewById(R.id.bottom_nav);
tabEntityList = new ArrayList<>();
	for (int i=0;i<tabText.length;i++){
         TabEntity item = new TabEntity();
         item.setText(tabText[i]);
         item.setNormalIconId(normalIcon[i]);
         item.setSelectIconId(selectIcon[i]);
         tabEntityList.add(item);
   }

设置默认颜色和选中颜色:

bottomBarLayout.setNormalTextColor(normalTextColor); 
bottomBarLayout.setSelectTextColor(selectTextColor);

设置tab数据:

bottomBarLayout.setTabList(tabEntityList);

点击监听:

 bottomBarLayout.setOnItemClickListener(new BottomBarLayout.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                Toast.makeText(MainActivity.this,position+"",Toast.LENGTH_SHORT).show();
            }
  });

bottombarlayout's People

Contributors

liuhao2018 avatar

Watchers

James Cloos avatar weis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.