# CoordinatorTabLayout
[![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](https://github.com/hugeterry/CoordinatorTabLayout/blob/master/LICENSE.txt)
[![Download](https://api.bintray.com/packages/hugeterry/CoordinatorTabLayout/CoordinatorTabLayout/images/download.svg) ](https://bintray.com/hugeterry/CoordinatorTabLayout/CoordinatorTabLayout/_latestVersion)
[中文版文档](README_CN.md)
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](showUI/show1.gif)
## Usage
### Step 1
Add the following to your build.gradle:
```groovy
dependencies {
compile 'cn.hugeterry.coordinatortablayout:coordinatortablayout:1.1.0'
}
```
### Step 2
Config in xml:
```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](showUI/show3.gif)</br>
Use it in your own code:</br>
1.`setTitle(String title)`:Set the CoordinatorTabLayout's title.</br>
2.`setupWithViewPager(ViewPager viewPager)`:To link the two together.</br>
3.`setImageArray(int[] imageArray)`:Set the image array of the header according to the number of tabs and pass it to the control.</br>
```java
//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](showUI/show2.gif)
`setImageArray(int[] imageArray, int[] colorArray)`:Set the color array to use for the content scrim for each tab.
```java
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](showUI/show4.png)
`setTransulcentStatusBar(Activity activity)`:Set translucent status bar,Support android4.4 and above.
```java
mCoordinatorTabLayout.setTransulcentStatusBar(activity);
```
### Set back enable
`setBackEnable(Boolean canBack)`:To enable the Up button for an activity that has a parent activity.
```java
@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.
```java
@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](https://github.com/hugeterry/CoordinatorTabLayout/blob/master/sample/src/main/java/cn/hugeterry/coordinatortablayoutdemo/LoadHeaderImageFromNetworkActivity.java)
### Gets the child control
`getActionBar()`:get the ActionBar<br/>
`getTabLayout()`:get the TabLayout<br/>
`getImageView()`:get the ImageView
[More code](https://github.com/hugeterry/CoordinatorTabLayout/blob/master/sample/src/main/java/cn/hugeterry/coordinatortablayoutdemo/MainActivity.java)
## Attributes
- `app:contentScrim` -> color.Defaults to ?attr/colorPrimary
- `app:tabIndicatorColor` -> color.
- `app:tabTextColor` -> color.
## Demo
[http://fir.im/ctlayout](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.
没有合适的资源?快使用搜索试试~ 我知道了~
一行代码使用TableLayout和CoordinatorLayout
共131个文件
xml:54个
java:13个
sample:9个
需积分: 16 8 下载量 179 浏览量
2017-09-26
14:47:48
上传
评论
收藏 12.4MB ZIP 举报
温馨提示
TabLayout和CoordinatorLayout相结合的依赖库,里边有demo可以参考修改,也可以来我的博客http://blog.csdn.net/huchengzhiqiang,找"TabLayout和CoordinatorLayout相结合的库的全面详解及修改"这篇博客
资源推荐
资源详情
资源评论
收起资源包目录
一行代码使用TableLayout和CoordinatorLayout (131个子文件)
gradlew.bat 2KB
fileSnapshots.bin 4.14MB
fileHashes.bin 411KB
taskArtifacts.bin 169KB
localClassSetAnalysis.bin 58KB
localClassSetAnalysis.bin 46KB
localJarClasspathSnapshot.bin 20KB
localJarClasspathSnapshot.bin 20KB
config 343B
description 73B
exclude 240B
.gitignore 506B
.gitignore 6B
.gitignore 6B
build.gradle 3KB
build.gradle 1011B
build.gradle 602B
settings.gradle 44B
gradlew 5KB
HEAD 197B
HEAD 197B
HEAD 32B
HEAD 23B
pack-88f4dfd424d298e00e0968b82917f7a14b2c1f38.idx 103KB
sample.iml 11KB
coordinatortablayout.iml 10KB
CoordinatorTabLayout.iml 892B
index 9KB
gradle-wrapper.jar 52KB
CoordinatorTabLayout.java 11KB
LoadHeaderImageFromNetworkActivity.java 5KB
MainActivity.java 3KB
MainFragment.java 2KB
RecyclerAdapter.java 1KB
MyPagerAdapter.java 982B
ExampleInstrumentedTest.java 801B
ExampleInstrumentedTest.java 796B
IntentUtils.java 666B
SystemView.java 516B
ExampleUnitTest.java 427B
ExampleUnitTest.java 427B
LoadHeaderImagesListener.java 311B
bg_other.jpg 120KB
bg_js.jpg 78KB
bg_ios.jpg 45KB
bg_android.jpg 36KB
localJarClasspathSnapshot.lock 17B
localClassSetAnalysis.lock 17B
localJarClasspathSnapshot.lock 17B
localClassSetAnalysis.lock 17B
taskArtifacts.lock 17B
master 197B
master 41B
README_CN.md 6KB
README.md 6KB
pack-88f4dfd424d298e00e0968b82917f7a14b2c1f38.pack 11.2MB
packed-refs 107B
ic_launcher.png 10KB
ic_launcher.png 8KB
ic_launcher.png 5KB
ic_launcher.png 3KB
ic_launcher.png 2KB
proguard-rules.pro 680B
proguard-rules.pro 680B
gradle.properties 747B
local.properties 554B
gradle-wrapper.properties 236B
pre-rebase.sample 5KB
update.sample 4KB
pre-commit.sample 2KB
pre-push.sample 1KB
prepare-commit-msg.sample 1KB
commit-msg.sample 896B
applypatch-msg.sample 478B
pre-applypatch.sample 424B
post-update.sample 189B
LICENSE.txt 11KB
workspace.xml 308KB
misc.xml 7KB
view_coordinatortablayout.xml 2KB
AndroidManifest.xml 803B
gradle.xml 695B
compiler.xml 686B
exposed_instrumentation_api_publish_0_5.xml 653B
activity_main.xml 636B
espresso_idling_resource_2_2_2.xml 635B
animated_vector_drawable_25_3_1.xml 624B
support_vector_drawable_25_3_1.xml 621B
support_media_compat_25_3_1.xml 612B
support_core_utils_25_3_1.xml 606B
espresso_core_2_2_2.xml 602B
support_fragment_25_3_1.xml 600B
recyclerview_v7_25_3_1.xml 597B
support_core_ui_25_3_1.xml 597B
support_compat_25_3_1.xml 594B
appcompat_v7_25_3_1.xml 588B
transition_25_3_1.xml 582B
design_25_3_1.xml 570B
javax_annotation_api_1_2.xml 569B
runner_0_5.xml 566B
共 131 条
- 1
- 2
资源评论
昊帅
- 粉丝: 12
- 资源: 28
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 【客户投诉系统】 Sringboot+vue+soap+activiti+mybatis+element-ui
- HengCe-2024-2030亚洲与中国马来酸酐接枝市场现状及未来发展趋势 -样本.docx
- 上海旅游统计数据-入境外国人按主要客源国分(人次)数据集
- Python基础-01:注释、变量、计算、打印
- c++冒泡排序从小到大,初学者使用
- AI进展下ChatGPT对文献情报工作的影响及启示
- 个人笔记的回归分析学习笔记-2
- HengCe-2024-2030中国棕榈脂肪粉市场现状研究分析与发展前景预测报告 -样本-lujing.docx
- 图解socket级别的sk-forward-alloc分配
- 北京市教育领域人工智能应用指南.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功