CoordinatorLayout에서 toolbar 쓸 때 조심해야할 점
툴바를 사용하고 싶었다.
1. 매니페스트테마 = noActionbar
액티비티.xml
<android.support.design.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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:minHeight="?attr/actionBarSize"/>
자바 oncreate() 안에
setSupportActionBar((Toolbar) findViewById(R.id.main_toolbar));
선언
근데 메뉴 이벤트도 안먹히고 다른 것과 겹쳐보인다.
activity_main
<android.support.design.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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/mainappbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/main_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark"
android:minHeight="?attr/actionBarSize"/>
</android.support.design.widget.AppBarLayout>
앱바레이아웃 선언해줘야함