添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
伤情的豆腐  ·  Spring注解@NoNull、@NotEm ...·  5 月前    · 
悲伤的沙滩裤  ·  Android unable to ...·  1 年前    · 
多情的酱肘子  ·  Digital Micrograph ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams
<?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"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
        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"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:elevation="0dp">
            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbarMainActivity"
                style="@style/CustomToolbar"
                android:background="@color/biscay"
                app:layout_scrollFlags="scroll|enterAlways">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageButton
                        android:id="@+id/icon_drawer_imagebutton"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_centerVertical="true"
                        android:background="@null"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        app:srcCompat="@drawable/ic_drawer" />
                    <RelativeLayout
                        android:gravity="center_horizontal"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                     android:layout_toLeftOf="@+id/icon_drawer_imagebutton">
                        <ImageButton
                            android:id="@+id/icon_logo_imagebutton"
                            android:layout_width="@dimen/size_logo"
                            android:layout_height="@dimen/size_logo"
                            android:layout_alignParentRight="true"
                            android:layout_centerVertical="true"
                            android:adjustViewBounds="true"
                            android:background="@null"
                            android:scaleType="fitXY"
                            app:srcCompat="@drawable/ic_logo_white" />
                        <TextView
                            android:id="@+id/nameUniversity_textview"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_centerHorizontal="true"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="10dp"
                            android:layout_marginRight="10dp"
                            android:textSize="18sp"
                         android:layout_toLeftOf="@+id/icon_logo_imagebutton"
                            android:gravity="center_vertical"
                            android:text="@string/nameUniversity"
                            android:textColor="@color/colorTextLight"
                            android:textStyle="bold" />
                    </RelativeLayout>
                </RelativeLayout>
            </androidx.appcompat.widget.Toolbar>
        </com.google.android.material.appbar.AppBarLayout>
        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tabsMainActivity"
            style="@style/CustomTabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/appBarLayout"
            app:tabGravity="fill"
            app:tabMode="fixed" />
        <androidx.viewpager.widget.ViewPager
            android:id="@+id/viewpagerMainActivity"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/tabsMainActivity"
            android:background="@color/colorTextLight" />
    </RelativeLayout>
    <!-- Navigation Drawer-->
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/drawerRecyclerView"
        android:layout_width="300dp"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:background="@color/gallery" />
</androidx.drawerlayout.widget.DrawerLayout>

And my library is:

implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:multidex:1.0.3'

But get me bellow error:

Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class com.google.android.material.appbar.AppBarLayout
Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.google.android.material.appbar.AppBarLayout
Caused by: java.lang.reflect.InvocationTargetException
                You really saved my day and I couldn't see this information anywhere thank you so much!!!
– K.tas
                May 25, 2020 at 7:15

You're using AndroidX tags-components which you already have AppCompat dependencies. This will cause other issues too. Go with the Refactor -> Migrate to AndoridX and add the mentioned dependency for the material components too.

In your build.gradle dependencies:

implementation 'com.google.android.material:material:1.0.0'

It's coming from Material components -> com.google.android.material as you can see so, that's why you get the error.

Remember to update the gradle in the other build.gradle too:

classpath 'com.android.tools.build:gradle:3.2.0'
                The same for the TabLayout > com.google.android.material.tabs.TabLayout. Adding the material dependency will solve the issue.
– ʍѳђઽ૯ท
                Oct 7, 2018 at 13:44
                I have already ` implementation 'com.google.android.material:material:1.2.1'` in my classpath but it not works.
– Dániel Kis
                Dec 9, 2020 at 18:50
                @DánielKis The question was for almost 2 years ago. However, If the provided solution didn't work for you, how about using Ask question of the website and opening another question with specific details?
– ʍѳђઽ૯ท
                Dec 9, 2020 at 19:57
implementation 'com.google.android.material:material:1.0.0'
classpath 'com.android.tools.build:gradle:3.2.0'

If you have added the above two conditions and it's still showing the error you can try a "LinearLayout" instead.

Check your /res/values/styles.xml and set your theme to

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar" />

or similar

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.