【问题标题】:Android: resource linkage failure, File not foundAndroid:资源联动失败,找不到文件
【发布时间】:2021-09-03 20:11:40
【问题描述】:

我正在我的应用程序中实现 Drawer Header,但说 Drawer_header.xml not found... 错误: C:\Users\SaifUllh\AndroidStudioProjects\QuizApp\app\src\main\res\layout\drawer_head.xml:16: AAPT: error: attribute android:style not found.

这里是代码

Drawer_header.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    android:padding="16dp"
    >



    <ImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:src="@drawable/ic_header_question" />

    <TextView

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:style="@style/TextAppearance.AppCompat.Subhead"
        android:text="Quiz yourself daily"
        android:textColor="@color/white" />

</LinearLayout>

这是我的 main_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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"
    tools:context=".MainActivity">

  <androidx.constraintlayout.widget.ConstraintLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent">


      <com.google.android.material.appbar.AppBarLayout
          android:id="@+id/appBarLayout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent">

          <com.google.android.material.appbar.MaterialToolbar
              android:id="@+id/appBar"
              style="@style/Widget.MaterialComponents.Toolbar.Primary"
              android:layout_width="match_parent"
              android:layout_height="?attr/actionBarSize"
              app:navigationIcon="@drawable/ic_hamberg"
              app:titleTextColor="@color/white"
              app:title="@string/app_name" />

      </com.google.android.material.appbar.AppBarLayout>


  </androidx.constraintlayout.widget.ConstraintLayout>


    <com.google.android.material.navigation.NavigationView
        android:layout_gravity="start"
        android:layout_width="wrap_content"
        app:headerLayout="@layout/drawer_head"
        app:menu="@menu/drawer_menu"
        android:layout_height="match_parent">

    </com.google.android.material.navigation.NavigationView>

</androidx.drawerlayout.widget.DrawerLayout>

【问题讨论】:

    标签: android xml android-layout layout navigation-drawer


    【解决方案1】:

    使用此代码:

    android:textAppearance="@style/TextAppearance.Compat.Subhead"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-05
      • 1970-01-01
      • 2017-11-26
      • 1970-01-01
      • 2021-02-23
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      相关资源
      最近更新 更多