繁体   English   中英

在 android 工作室中使用 CoordinatorTabLayout 时出现错误

[英]I am getting error while using CoordinatorTabLayout in android studio

Class referenced in the layout file, cn.hugeterry.coordinatortablayout.CoordinatorTabLayout, was not found in the project or the libraries中找到这里错误的屏幕截图点击这里

<?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>

你添加了cn.hugeterry.coordinatortablayout.CoordinatorTabLayout布局的依赖? 因为这是自定义的Layout ,不是android提供的Layout。 您必须添加依赖项才能使用自定义布局。 如果您使用 android 默认coordinator器布局,那么这不是 android 默认值。 android 默认布局如下。

<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>

如果您的 coordinatorLayout 是 android 默认值,那么按照我上面添加的方式进行布局。 如果问题相同,请告诉我

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM