Android: Custom action bar,How to use entire width?

前端 未结 5 905
梦如初夏
梦如初夏 2020-12-10 04:54

Here is an image of my custom action bar:

\"enter

I want to use the entire wid

5条回答
  •  北海茫月
    2020-12-10 05:44

    Follow few simple steps. 1. Make your own custom Action view action_view.xml

    
    
    
    
    
    
        
    

    Here is the code:

     final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.custom_action_bar, null);
    actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    

    This will surely solve your purpose. Happy Coding !!!

提交回复
热议问题