[안드로이드] 앱 바(App Bar), 액션바(ActionBar), 툴바(Toolbar)는 무엇인가?

프로그래밍/Android 관련2018. 1. 28. 14:56

안녕하세요. 개발자 드리머즈입니다.


안드로이드 App 개발을 하다보면 앱 바, 액션바, 툴바에 대해 마주치게 됩니다. 서로 이름도 비슷합니다.

가장 상위 개념인 앱 바(App Bar)부터 보겠습니다. 영어 안드로이드 디벨로퍼 사이트의 설명을 인용하겠습니다. (한국어 안드로이드 디벨로퍼 사이트는 번역이 좀 이상하게 된 경우가 있어 혼동의 여지가 있음)


The app bar, also known as the action bar, is one of the most important design elements in your app's activities, because it provides a visual structure and interactive elements that are familiar to users. Using the app bar makes your app consistent with other Android apps, allowing users to quickly understand how to operate your app and have a great experience. 

 앱 바(=액션바)에 대한 설명이 위에 있지만 아래 사진으로 보면 더 쉽게 이해가 됩니다. 그리고 앱 바(app bar)는 액션바(action bar)로 불린다고 합니다.



위의 사진에서 빨간색으로 표시한 Activity의 상단에서 자주 볼 수 있는 타이틀과 버튼을 달 수 있는 영역이 바로 app Bar(또는 action Bar)입니다. 안드로이드에서 앱 바를 제공하기 때문에 이를 사용하는 App들은 일관적인 디자인을 가지게 되고 따라서 사용자들은 처음 사용하는 App에서 App Bar를 발견하더라도 손쉽게 작동법을 알 수 있습니다.


위 글에서 action bar를 app bar와 같은 의미로 이야기했습니다. 하지만 우리가 엄밀히 말하면 조금 다르다고 보는 게 좋을 것 같습니다. app bar로 사용가능한 게 2가지가 있는데, 하나는 ActionBar이고 나머지 하나는 Toolbar입니다. 구글 디벨로퍼 사이트에서 서로 비슷한 개념인 ActionBar와 Toolbar가 함께 존재하게 됐는지를 살펴 보겠습니다.


Beginning with Android 3.0 (API level 11), all activities that use the default theme have an ActionBar as an app bar. However, app bar features have gradually been added to the native ActionBar over various Android releases. As a result, the native ActionBar behaves differently depending on what version of the Android system a device may be using. By contrast, the most recent features are added to the support library's version of Toolbar, and they are available on any device that can use the support library.

For this reason, you should use the support library's Toolbar class to implement your activities' app bars. Using the support library's toolbar helps ensure that your app will have consistent behavior across the widest range of devices. For example, the Toolbar widget provides a material design experience on devices running Android 2.1 (API level 7) or later, but the native action bar doesn't support material design unless the device is running Android 5.0 (API level 21) or later.

안드로이드의 역사와 관련이 있습니다. 안드로이드 버전 3.0부터 디폴트 테마(Theme)를 사용하는 모든 액티비티는 ActionBar를 app bar로 사용한다고 합니다. 그런데 새로운 버전의 안드로이드가 출시되면서 app bar 피쳐들이 점점 더 natvie ActionBar(OS에 기본적으로 포함된 ActionBar를 의미함. 반대되는 개념으로 지원 라이브러리에 포함된 ActionBar가 있음)에 추가되었고 그 결과 native ActionBar는 Android OS 버전에 따라 다르게 동작되는 문제가 생겼습니다. 이와 대조적으로 최신 피쳐들은 지원 라이브러리에 포함된 Toolbar에 추가되고 있어, 지원 라이브러리를 사용할 수 있는 모든 단말은 그 피쳐를 이용할 수 있습니다.


이 때문에 app bar 구현을 위해서 지원 라이브러리의 Toolbar를 사용해야 한다고 강조합니다. 왜냐하면 지원 라이브러리는 apk내에 포함되기 때문에 여러 단말에서 일정한 동작을 하도록 보장하는데 도움이 되기 때문입니다. 그냥 간단하게 app bar를 구성할 때 호환성을 위해 지원 라이브러리 내부에 존재하는 Toolbar를 사용해야하는구나 하고 기억하시면 될 것 같습니다.


참고로 OS내부에 포함된 native ActionBar와 apk 내부에 포함되는 지원 라이브러리 내에 존재하는 ActionBar는 클래스 이름(패키지 경로)이 다릅니다.

Toolbar도 마찬가지 입니다.


android.support.v7.app.ActionBar (지원 라이브러리 내에 존재하는 ActionBar)

android.app.ActionBar (OS 내부에 존재하는 native ActionBar)


android.support.v7.widget.Toolbar (지원 라이브러리 내에 존재하는 Toolbar)

android.widget.Toolbar (OS 내부에 존재하는 native Toolbar)


작성자

Posted by 드리머즈

관련 글

댓글 영역