Skip to content Skip to sidebar Skip to footer

Android: Action Bar Home Button Customize

I am developing an application in which what the need in action bar is shown in image: I need to apply back arrow with text and search icon custom from drawable. My API level is f

Solution 1:

Using AppCompat is better option but still if you dont want to use it, set custom view in actionbar. This might be helpful when you are using custom fonts in text.

See this Reference for more info.

Like this,

LinearLayout customView = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.custom_actionbar_layout, null);
ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER_VERTICAL);
getActionBar().setCustomView(customView, params);

Hope it will help you!

Solution 2:

setHomeAsUpIndicator was introduced with API level 18, and the device where you are experiencing the crash has a version of android older than 18. To overcome it you can use appcompat

Post a Comment for "Android: Action Bar Home Button Customize"