{"id":13641074,"url":"https://github.com/hugeterry/CoordinatorTabLayout","last_synced_at":"2025-04-20T07:31:55.777Z","repository":{"id":201274130,"uuid":"80210218","full_name":"hugeterry/CoordinatorTabLayout","owner":"hugeterry","description":"Combination of TabLayout and CoordinatorLayout./TabLayout和CoordinatorLayout相结合的折叠控件","archived":false,"fork":false,"pushed_at":"2019-12-25T03:38:34.000Z","size":11528,"stargazers_count":4184,"open_issues_count":19,"forks_count":585,"subscribers_count":85,"default_branch":"master","last_synced_at":"2024-10-29T17:55:55.957Z","etag":null,"topics":["android","android-library","coordinatorlayout","tablayout"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hugeterry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-01-27T13:40:28.000Z","updated_at":"2024-10-24T09:14:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"286e3d20-6260-4a8b-9035-1253892a37c7","html_url":"https://github.com/hugeterry/CoordinatorTabLayout","commit_stats":null,"previous_names":["hugeterry/coordinatortablayout"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugeterry%2FCoordinatorTabLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugeterry%2FCoordinatorTabLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugeterry%2FCoordinatorTabLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugeterry%2FCoordinatorTabLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hugeterry","download_url":"https://codeload.github.com/hugeterry/CoordinatorTabLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223822036,"owners_count":17208789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","coordinatorlayout","tablayout"],"created_at":"2024-08-02T01:01:17.507Z","updated_at":"2024-11-09T11:30:42.349Z","avatar_url":"https://github.com/hugeterry.png","language":"Java","funding_links":[],"categories":["TabLayout"],"sub_categories":[],"readme":"# CoordinatorTabLayout\n\n[![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](https://github.com/hugeterry/CoordinatorTabLayout/blob/master/LICENSE.txt)\n[![Download](https://api.bintray.com/packages/hugeterry/CoordinatorTabLayout/CoordinatorTabLayout/images/download.svg) ](https://bintray.com/hugeterry/CoordinatorTabLayout/CoordinatorTabLayout/_latestVersion)\n\n[中文版文档](README_CN.md)\n\nCoordinatorTabLayout is a custom composite control that quickly implements the combination of TabLayout and CoordinatorLayout.\nInherited to the CoordinatorLayout, in the following components used CollapsingToolbarLayout contains TabLayout.\n\n![show](showUI/show1.gif)\n\n\n## Usage\n\n### Step 1\n\nAdd the following to your build.gradle:\n```groovy\ndependencies {\n    compile 'cn.hugeterry.coordinatortablayout:coordinatortablayout:1.2.2'\n}\n```\n\n### Step 2\n\nConfig in xml:\n```xml\n\u003ccn.hugeterry.coordinatortablayout.CoordinatorTabLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    android:id=\"@+id/coordinatortablayout\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n    \u003candroid.support.v4.view.ViewPager\n        android:id=\"@+id/vp\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        app:layout_behavior=\"@string/appbar_scrolling_view_behavior\" /\u003e\n\u003c/cn.hugeterry.coordinatortablayout.CoordinatorTabLayout\u003e\n```\n\n\n### Step 3\n\n![show](showUI/show3.gif)\u003c/br\u003e\nUse it in your own code:\u003c/br\u003e\n1.`setTitle(String title)`:Set the CoordinatorTabLayout's title.\u003c/br\u003e\n2.`setupWithViewPager(ViewPager viewPager)`:To link the two together.\u003c/br\u003e\n3.`setImageArray(int[] imageArray)`:Set the image array of the header according to the number of tabs and pass it to the control.\u003c/br\u003e\n```java\n        //Add the fragment to the viewpager\n        initFragments();\n        initViewPager();\n        //Image array\n        mImageArray = new int[]{\n                R.mipmap.bg_android,\n                R.mipmap.bg_ios,\n                R.mipmap.bg_js,\n                R.mipmap.bg_other};\n\n        mCoordinatorTabLayout = (CoordinatorTabLayout) findViewById(R.id.coordinatortablayout);\n        mCoordinatorTabLayout.setTitle(\"Demo\")\n                .setImageArray(mImageArray)\n                .setupWithViewPager(mViewPager);\n```\n\nFinish, enjoy it.\n\n\n## More\n\n### Set the content scrim\n\n![show](showUI/show2.gif)\n\n`setImageArray(int[] imageArray, int[] colorArray)`:Set the color array to use for the content scrim for each tab.\n```java\n        mColorArray = new int[]{\n                android.R.color.holo_blue_light,\n                android.R.color.holo_red_light,\n                android.R.color.holo_orange_light,\n                android.R.color.holo_green_light};\n        mCoordinatorTabLayout.setImageArray(mImageArray, mColorArray);\n ```\n\n### Set translucent status bar\n\n![show](showUI/show4.png)\n\n`setTranslucentStatusBar(Activity activity)`:Set translucent status bar,Support android4.4 and above.\n```java\nmCoordinatorTabLayout.setTranslucentStatusBar(activity);\n```\n\n### Set translucent navigation bar\n\n![show](showUI/show5.jpg)\n\n`setTranslucentNavigationBar(Activity activity)`:Set translucent navigation bar,Support android4.4 and above.\n```java\nmCoordinatorTabLayout.setTranslucentNavigationBar(activity);\n```\n\n### Set back enable\n`setBackEnable(Boolean canBack)`:To enable the Up button for an activity that has a parent activity.\n```java\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        ...\n        mCoordinatorTabLayout.setBackEnable(true);\n        ...\n    }\n    @Override\n    public boolean onOptionsItemSelected(MenuItem item) {\n        if (item.getItemId() == android.R.id.home) {\n            finish();\n        }\n        return super.onOptionsItemSelected(item);\n    }\n```\n\n### Load header images from network\n\n`setLoadHeaderImagesListener(LoadHeaderImagesListener loadHeaderImagesListener)`:Set the listener that gets the header images.\n```java\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        ...\n        mCoordinatorTabLayout.setTitle(\"Demo\")\n                .setBackEnable(true)\n                .setContentScrimColorArray(mColorArray)\n                .setLoadHeaderImagesListener(new LoadHeaderImagesListener() {\n                    @Override\n                    public void loadHeaderImages(ImageView imageView, TabLayout.Tab tab) {\n                        switch (tab.getPosition()) {\n                            case 0:\n                                //load header images\n                                break;\n                            ...\n                        }\n                    }\n                })\n                .setupWithViewPager(mViewPager);\n    }\n```\nYou also can load header images using glide/picasso，[Sample](https://github.com/hugeterry/CoordinatorTabLayout/blob/master/sample/src/main/java/cn/hugeterry/coordinatortablayoutdemo/LoadHeaderImageFromNetworkActivity.java)\n\n### Set the behavior mode for the Tabs in this layout\n\n`setTabMode(@TabLayout.Mode int mode)`:The valid input options are:MODE_FIXED,MODE_SCROLLABLE\n```java\nmCoordinatorTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);\n```\n\n### Add a CoordinatorTabLayout.OnTabSelectedListener\n\n`addOnTabSelectedListener(OnTabSelectedListener onTabSelectedListener)`:Add a CoordinatorTabLayout.OnTabSelectedListener that will be invoked when tab selection changes.\n```java\nmCoordinatorTabLayout.addOnTabSelectedListener(new OnTabSelectedListener() {\n                         @Override\n                         public void onTabSelected(TabLayout.Tab tab) {\n\n                         }\n\n                         @Override\n                         public void onTabUnselected(TabLayout.Tab tab) {\n\n                         }\n\n                         @Override\n                         public void onTabReselected(TabLayout.Tab tab) {\n\n                         }\n                     })\n```\n\n### Gets the child control\n`getActionBar()`:get the ActionBar\u003cbr/\u003e\n`getTabLayout()`:get the TabLayout\u003cbr/\u003e\n`getImageView()`:get the ImageView\n\n[More code](https://github.com/hugeterry/CoordinatorTabLayout/blob/master/sample/src/main/java/cn/hugeterry/coordinatortablayoutdemo/MainActivity.java)\n\n\n## Attributes\n- `app:contentScrim` -\u003e color.Defaults to ?attr/colorPrimary\n- `app:tabIndicatorColor` -\u003e color.\n- `app:tabTextColor` -\u003e color.\n\n## Demo\n[http://fir.im/ctlayout](http://fir.im/ctlayout)\n\n## LICENSE\n    Copyright 2017 HugeTerry.\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugeterry%2FCoordinatorTabLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugeterry%2FCoordinatorTabLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugeterry%2FCoordinatorTabLayout/lists"}