Support
Quality
Security
License
Reuse
kandi has reviewed CoordinatorTabLayout and discovered the below as its top functions. This is intended to give you an instant insight into CoordinatorTabLayout implemented functionality, and help decide if they suit your requirements.
Combination of TabLayout and CoordinatorLayout./TabLayout和CoordinatorLayout相结合的折叠控件
Step 1
dependencies {
compile 'cn.hugeterry.coordinatortablayout:coordinatortablayout:1.2.2'
}
Step 2
<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
//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);
Set the content scrim
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
mCoordinatorTabLayout.setTranslucentStatusBar(activity);
Set translucent navigation bar
mCoordinatorTabLayout.setTranslucentNavigationBar(activity);
Set back enable
@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
@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);
}
Set the behavior mode for the Tabs in this layout
mCoordinatorTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
Add a CoordinatorTabLayout.OnTabSelectedListener
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) {
}
})
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.
I am getting error while using CoordinatorTabLayout in android studio
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.coordinatorlayout.widget.CoordinatorLayout>
QUESTION
I am getting error while using CoordinatorTabLayout in android studio
Asked 2022-Apr-14 at 09:11I am getting an error Class referenced in the layout file, cn.hugeterry.coordinatortablayout.CoordinatorTabLayout, was not found in the project or the libraries
while importing CoordiatorTabLayout in android studio
here screenshot of the error
<?xml version="1.0" encoding="utf-8"?>
<cn.hugeterry.coordinatortablayout.CoordinatorTabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinatortablayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.prosec.Safety">
<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>
ANSWER
Answered 2022-Apr-14 at 08:42You added dependency of cn.hugeterry.coordinatortablayout.CoordinatorTabLayout
layout? Because this is custom Layout
, not android provided Layout. You have to add the dependency to use a custom Layout. If you use the android default coordinator
layout then this is not android default. The android default layout is below.
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.coordinatorlayout.widget.CoordinatorLayout>
If your coordinatorLayout is android default then make your layout as above I added. If problem is same, let me know
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Save this library and start creating your kit