How to set Home-Icon fields when using setDisplayHomeAsUpEnabled (true)?

I have a problem with my own action bar (not ABS). In normal condition, the icon has 26 px fields on both sides.

enter image description here

But when I call setDisplayHomeAsUpEnabled (true) , it reduces these fields and as a result looks much narrower.

enter image description here

Do you have an idea how to save this margin when setDisplayHomeAsUpEnabled (true) is called? ( mostly without workarounds and user views)

Thanks in advance.

+4
source share
1 answer

You can set the size of the home icon as follows: (just call the code below inside the Activity onCreate(...) method)

 ImageView ivIcon = (ImageView) findViewById(android.R.id.home); FrameLayout.LayoutParams lpIcon = (FrameLayout.LayoutParams) ivIcon.getLayoutParams(); lpIcon.topMargin = lpIcon.bottomMargin = yourmargin; lpIcon.leftMargin = lpIcon.rightMargin = yourmargin; ivIcon.setLayoutParams(lpIcon); 

Its kind of hack , but I used it to completely get rid of the field by setting it to 0.

+1
source

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


All Articles