How should I import Toolbar tool in android studio?

前端 未结 1 452
庸人自扰
庸人自扰 2020-12-12 02:36

I am trying to add a Toolbar to my android studio project. I found several explanations of how should I do it and they all explained these steps. In the first s

相关标签:
1条回答
  • 2020-12-12 03:00

    Since you are using Androidx libraries you have to:

    • use the right class in your code import androidx.appcompat.widget.Toolbar.
    • use the right AppCompativity: import androidx.appcompat.app.AppCompatActivity;
    • use <androidx.appcompat.widget.Toolbar in your layout

    If you want to use the Material Components Library

    • add the library implementation 'com.google.android.material:material:<version>'
    • follow the getting started page to change the theme to a Theme.MaterialComponents.* theme
    • Use the com.google.android.material.appbar.MaterialToolbar in your code and in your layout
    0 讨论(0)
提交回复
热议问题