【发布时间】:2021-02-25 21:16:04
【问题描述】:
我的应用程序在启动时崩溃,这就是我得到的错误 com.google.android.material.appbar.AppBarLayout 无法转换为 androidx.appcompat.widget.Toolbar
这是我的 XML 文件
<LinearLayout
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"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mToolBar">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/logo"/>
<TextView
android:id="@+id/profileText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text=" Hello"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="italic|bold" />
</androidx.appcompat.widget.Toolbar>
<com.google.android.material.tabs.TabLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tabLayout"
app:tabTextColor="#000"
app:tabSelectedTextColor="#fff"/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewPager"/>
我被定向到这行代码mToolBar = findViewById(R.id.mToolBar);
我尝试更改
【问题讨论】:
标签: android xml material-design