How to add indentation / markup between the icon and the Up-Button ActionBar?

I need to set the 10dp field between the up button and the icon, 5 dp between the icon and the title in the default action bar (android 4.2.2). Can anyone suggest how to do this.

I don’t want to create custom action bars, since my requirements are exactly the same as the default action bar with a change in height, and adding between the icon, the up button and the title bar. Also resize the text.

Can this be done using the defualt action bar. I can change the height of the action bar.

+4
source share
1 answer

You can add padding / edge by getting an ImageView of the icon from the ActionBar.

Here's how to do it:

ImageView icon = (ImageView) findViewById(android.R.id.home); FrameLayout.LayoutParams iconLp = (FrameLayout.LayoutParams) icon.getLayoutParams(); iconLp.topMargin = iconLp.bottomMargin = 0; icon.setLayoutParams(iconLp); 

Edit: Use this code, for example, in the Activity onCreate method.

+4
source

Source: https://habr.com/ru/post/1501058/


All Articles