How to change HomeAsUp indicator in new AppCompat Toolbar?

后端 未结 6 1791
既然无缘
既然无缘 2020-12-28 15:01

I wanna change default ActionBar homeAsUp indicator (drawable) in my AppCompat Toolbar. How to achieve that? Only default arrow shows up.

styles (same for other API\

6条回答
  •  忘掉有多难
    2020-12-28 15:30

    Unfortunately, if this style line is used in a commonly shared AppCompat ToolBar/App bar with other activities in the App, including the main activity, the "navigationIcon" specified will be automatically shown, unlike the standard default HomeAsUpIndicator, which is not shown unless explicitly enabled as desired in an Activity, typically as follows: (in the onCreate())

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    

    With the above style line, since it behaves in an opposite manner, in a similar fashion, the indicator needs to be explicitly disabled if it is not desired to be shown, as on the main activity, as follows: (in the onCreate())

    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    

    (as observed on Android 4.0.4, 4.3, and 4.4.2 phones)

提交回复
热议问题