All Projects → hugeterry → Coordinatortablayout

hugeterry / Coordinatortablayout

Licence: apache-2.0
Combination of TabLayout and CoordinatorLayout./TabLayout和CoordinatorLayout相结合的折叠控件

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Coordinatortablayout

Mao Rn Android Kit
⚙️ Android Native (ui components and modules) wrap in React Native
Stars: ✭ 74 (-98.2%)
Mutual labels:  coordinatorlayout, tablayout
Materialdesignsamples
Material Design 系列控件samples,讲了Material Design 系列新控件的使用方法和一些场景示例,使用详情请看对应博客,持续更新中...
Stars: ✭ 900 (-78.12%)
Mutual labels:  coordinatorlayout, tablayout
MaterialDesignSample
Android transition元素共享动画、CoordinatorLayout、AppBarLayout、FloatingActionButton、BottomSheet、SnackBar、自定义behavior实现动画效果。
Stars: ✭ 28 (-99.32%)
Mutual labels:  coordinatorlayout
Flowhelper
帮助您迅速构建顶部Tab,比如今日头条效果,热搜、搜索记录、与ViewPager/ViewPager2搭配的工具类;
Stars: ✭ 295 (-92.83%)
Mutual labels:  tablayout
tablayout-ext
⭐🎉google 原生 Tablayout( com.google.android.material.tabs.TabLayout) 零入侵拓展,帮你更便捷的使用原生TabLayout实现一些UI效果
Stars: ✭ 69 (-98.32%)
Mutual labels:  tablayout
un-material-tab
(deprecated) Custom tab layout which can be used as a material TabLayout alternative and contains basic functionality which Google's TabLayout has.
Stars: ✭ 83 (-97.98%)
Mutual labels:  tablayout
ELeMaList
仿饿了么商品列表页面
Stars: ✭ 43 (-98.95%)
Mutual labels:  coordinatorlayout
multilayout
一个可以支持自动将分类标签拆分多行Tab标签的Layout
Stars: ✭ 14 (-99.66%)
Mutual labels:  tablayout
Playtablayout
PlayTabLayout is a tab layout very similar to Google Play tab layout. The main feature is that ripple shows in a particular place where user taps.
Stars: ✭ 319 (-92.25%)
Mutual labels:  tablayout
BottomNavigationView
Bottom Navigation Example
Stars: ✭ 15 (-99.64%)
Mutual labels:  tablayout
Eleme Master
高仿饿了么3.0版本点餐页面
Stars: ✭ 297 (-92.78%)
Mutual labels:  coordinatorlayout
KeepSafeNew
Sample app to demonstrate MVP (Model - View - Presenter), Android Architecture Components (Room Persistence, LiveData), RxJava2, ButterKnife in Android.
Stars: ✭ 58 (-98.59%)
Mutual labels:  coordinatorlayout
CoolCoodinatorLayout
banner沉浸式+滚动视差+悬浮搜索框+标题置顶复杂联动效果
Stars: ✭ 46 (-98.88%)
Mutual labels:  coordinatorlayout
Xtablayout
🧀Enhanced version of TabLayout, add the custom width of the TabLayout Indicator, add the animation effect of Weibo navigation bar, support the Indicator rounded effect, support the TAB to add red dots and Numbers.
Stars: ✭ 264 (-93.58%)
Mutual labels:  tablayout
JSTabLayout
简书tablayout
Stars: ✭ 29 (-99.3%)
Mutual labels:  tablayout
Xamarin Forms Tab Badge
Xamarin Forms bindable Tab badges for iOS, Android, UWP, MacOS and WPF
Stars: ✭ 304 (-92.61%)
Mutual labels:  tablayout
LiteRefresh
Nested scrolling UI library for Android based on CoordinatorLayout. Pull-to-refresh and pull-to-load-more are supported.
Stars: ✭ 37 (-99.1%)
Mutual labels:  coordinatorlayout
NestedScrollingDemo
😋😋😋A good app for understanding android nested scrolling
Stars: ✭ 98 (-97.62%)
Mutual labels:  coordinatorlayout
TabLayout
在原design包中的TabLayout的基础上增加了一些实用的属性.
Stars: ✭ 25 (-99.39%)
Mutual labels:  tablayout
Changetablayout
[停止维护]一款炫酷的TabLayout
Stars: ✭ 345 (-91.61%)
Mutual labels:  tablayout

CoordinatorTabLayout

License Download

中文版文档

CoordinatorTabLayout is a custom composite control that quickly implements the combination of TabLayout and CoordinatorLayout. Inherited to the CoordinatorLayout, in the following components used CollapsingToolbarLayout contains TabLayout.

show

Usage

Step 1

Add the following to your build.gradle:

dependencies {
    compile 'cn.hugeterry.coordinatortablayout:coordinatortablayout:1.2.2'
}

Step 2

Config in xml:

<cn.hugeterry.coordinatortablayout.CoordinatorTabLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinatortablayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.view.ViewPager
        android:id="@+id/vp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</cn.hugeterry.coordinatortablayout.CoordinatorTabLayout>

Step 3

show
Use it in your own code:
1.setTitle(String title):Set the CoordinatorTabLayout's title.
2.setupWithViewPager(ViewPager viewPager):To link the two together.
3.setImageArray(int[] imageArray):Set the image array of the header according to the number of tabs and pass it to the control.

        //Add the fragment to the viewpager
        initFragments();
        initViewPager();
        //Image array
        mImageArray = new int[]{
                R.mipmap.bg_android,
                R.mipmap.bg_ios,
                R.mipmap.bg_js,
                R.mipmap.bg_other};

        mCoordinatorTabLayout = (CoordinatorTabLayout) findViewById(R.id.coordinatortablayout);
        mCoordinatorTabLayout.setTitle("Demo")
                .setImageArray(mImageArray)
                .setupWithViewPager(mViewPager);

Finish, enjoy it.

More

Set the content scrim

show

setImageArray(int[] imageArray, int[] colorArray):Set the color array to use for the content scrim for each tab.

        mColorArray = new int[]{
                android.R.color.holo_blue_light,
                android.R.color.holo_red_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_green_light};
        mCoordinatorTabLayout.setImageArray(mImageArray, mColorArray);

Set translucent status bar

show

setTranslucentStatusBar(Activity activity):Set translucent status bar,Support android4.4 and above.

mCoordinatorTabLayout.setTranslucentStatusBar(activity);

Set translucent navigation bar

show

setTranslucentNavigationBar(Activity activity):Set translucent navigation bar,Support android4.4 and above.

mCoordinatorTabLayout.setTranslucentNavigationBar(activity);

Set back enable

setBackEnable(Boolean canBack):To enable the Up button for an activity that has a parent activity.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ...
        mCoordinatorTabLayout.setBackEnable(true);
        ...
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }

Load header images from network

setLoadHeaderImagesListener(LoadHeaderImagesListener loadHeaderImagesListener):Set the listener that gets the header images.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ...
        mCoordinatorTabLayout.setTitle("Demo")
                .setBackEnable(true)
                .setContentScrimColorArray(mColorArray)
                .setLoadHeaderImagesListener(new LoadHeaderImagesListener() {
                    @Override
                    public void loadHeaderImages(ImageView imageView, TabLayout.Tab tab) {
                        switch (tab.getPosition()) {
                            case 0:
                                //load header images
                                break;
                            ...
                        }
                    }
                })
                .setupWithViewPager(mViewPager);
    }

You also can load header images using glide/picasso,Sample

Set the behavior mode for the Tabs in this layout

setTabMode(@TabLayout.Mode int mode):The valid input options are:MODE_FIXED,MODE_SCROLLABLE

mCoordinatorTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);

Add a CoordinatorTabLayout.OnTabSelectedListener

addOnTabSelectedListener(OnTabSelectedListener onTabSelectedListener):Add a CoordinatorTabLayout.OnTabSelectedListener that will be invoked when tab selection changes.

mCoordinatorTabLayout.addOnTabSelectedListener(new OnTabSelectedListener() {
                         @Override
                         public void onTabSelected(TabLayout.Tab tab) {

                         }

                         @Override
                         public void onTabUnselected(TabLayout.Tab tab) {

                         }

                         @Override
                         public void onTabReselected(TabLayout.Tab tab) {

                         }
                     })

Gets the child control

getActionBar():get the ActionBar
getTabLayout():get the TabLayout
getImageView():get the ImageView

More code

Attributes

  • app:contentScrim -> color.Defaults to ?attr/colorPrimary
  • app:tabIndicatorColor -> color.
  • app:tabTextColor -> color.

Demo

http://fir.im/ctlayout

LICENSE

Copyright 2017 HugeTerry.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].