xml
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:navigationIcon="?attr/homeAsUpIndicator"
app:title="툴바"
app:titleCentered="true" />
activity
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initToolbar()
}
private fun initToolbar() {
setSupportActionBar(binding.toolbar)
}
override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}
actionmenu 안쓰면 onOptionsItemSelected 구현 필요없이 간단하게 가능
반응형
'android > study' 카테고리의 다른 글
basicwidget (0) | 2018.04.08 |
---|---|
layout (0) | 2018.04.08 |