hegunhee / Android_basic_library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

액션바 햄버거 버튼 구현

hegunhee opened this issue · comments

배경

  • 프로젝트에 들어가기 전 액션바의 햄버거 버튼을 이용해 drawerLayout을 열려고함
  • 액션바 버튼에 햄버거 버튼을 달고 리스너를 달아야함

image
toolbar를 이용해 액션바로 만들어주고
setDisplayHomeAsUpEnabled를 true로 지정해주면 액션바 맨 왼쪽에 백버튼이 생기게됨
여기서 setHomeAsUpIndicatior에 drawable을 지정해주면 해당 백버튼이 지정한 아이콘으로 변경됨

image
onOptionsItemSelected 메서드를 재정의해 android.R.id.home 구문을 이용하면 리스너 설정 가능