개발모음집

CoordinatorLayout에서 toolbar 쓸 때 조심해야할 점 본문

Android

CoordinatorLayout에서 toolbar 쓸 때 조심해야할 점

void 2017. 5. 23. 12:09

툴바를 사용하고 싶었다.


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>


앱바레이아웃 선언해줘야함

'Android' 카테고리의 다른 글

Fragment already active 에러  (0) 2017.05.29
구글 로그인API token null 문제  (0) 2017.05.29
프래그먼트 에러  (0) 2017.05.22
안드로이드 앱바 삭제하는 4가지 방법  (0) 2017.05.19
프래그먼트 정리  (0) 2017.05.17