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