Git Product home page Git Product logo

androidtablayout's Introduction

tablayout

app底部tab切换布局

#Effect

image image

#strengths 1、动态设置tab,方便,易于使用。 2、可以加载网络图标。 3、支持设置消息的数量以清除消息的数量。 4、支持水平和垂直布局。 5、支持动画显示和隐藏。

#Edition

    1.0.1版本:
    1、添加底部tab布局显示和隐藏方法。
    2、抽离glide,回调设置网络图片便于使用其他图片框架加载。


    1.0.0版本
    1、动态设置tab,方便使用。
    2、可以设置本地图片和网络图片。
    3、支持水平和竖直布局。
    4、支持设置消息的数量以清除消息的数量。

#use

gradle:

             dependencies {
                  compile 'com.dalong:tablayout:1.0.1'
             }

xml:

            <com.dalong.tablayout.TabLayout
                   android:id="@+id/horizontal_bottomtab"
                   android:layout_width="match_parent"
                   android:orientation="horizontal"
                   android:layout_alignParentBottom="true"
                   android:layout_height="wrap_content"/>             

java:

   mTabLayout=(BottomTabLayout)findViewById(R.id.mBottomTabLayout);
   mTabLayout.setOnTabChangeListener(new TabLayout.OnTabChangeListener() {
              @Override
              public void onTabSelect(int position) {
                  Toast.makeText(MainActivity.this, "您选择了"+position, Toast.LENGTH_SHORT).show();
              }
  
              @Override
              public void onTabSelected(int position) {
                  Toast.makeText(MainActivity.this, "您已经选择了"+position, Toast.LENGTH_SHORT).show();
              }
    });
    
      mTabLayout.setOnSetTabIconListener(new TabLayout.OnSetTabNetworkIconListener() {
                @Override
                public void setTabNetworkIcon(ImageView mTabIcon, int defaultIcon, String iconUrl, int position, boolean isSelect) {
                    Glide.with(HorizontalTabActivity.this)
                            .load(iconUrl)
                            .diskCacheStrategy(DiskCacheStrategy.ALL)
                            .placeholder(defaultIcon)
                            .into(mTabIcon);
                }
            });

   //Set the number of red points corresponding to index
   mTabLayout.setTabNum(new Random().nextInt(4),new Random().nextInt(100));
   
   //Clear all messages
   mTabLayout.clearAllTabNum();
   
   //Clear the corresponding location of the message
   mTabLayout.clearTabNum(1);
   
   //show tab
   mTabLayout.showTab();
   
   //hide tab
   mTabLayout.hideTab();

#Thank glide

androidtablayout's People

Watchers

James Cloos avatar NickMing 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.