remove padding around action bar left icon on Android 4.0+

前端 未结 6 1910
孤街浪徒
孤街浪徒 2020-11-29 01:57

I want to remove the padding around the icon on the left in the standard android 4.0+ action bar. I\'m setting the icon with:

getActionBar().setIcon(getResou         


        
6条回答
  •  孤街浪徒
    2020-11-29 02:31

    Enhanced parrzhang reply in remove padding around action bar left icon on Android 4.0+

     private void adjustHomeButtonLayout(){
            ImageView view = (ImageView)findViewById(android.R.id.home);
            if(view.getParent() instanceof ViewGroup){
                ViewGroup viewGroup = (ViewGroup)view.getParent();
                View upView = viewGroup.getChildAt(0);
                if(upView != null && upView.getLayoutParams() instanceof FrameLayout.LayoutParams){
                    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) upView.getLayoutParams();
                    layoutParams.width = 20;// **can give your own width**
                    upView.setLayoutParams(layoutParams);
                }
            }
        }
    

提交回复
热议问题