zoukankan      html  css  js  c++  java
  • ActionBar设置自定义setCustomView()留有空白的问题

    1. 先来看问题,当我使用ActionBar的时候,设置setCustomView时,会留有空白的处理
    2. 网上很多朋友说可以修改V7包到19,结果处理的效果也是不理想的.
    3. 下面贴出我觉得靠谱的处理代码
      1. publicclassMainActivityextendsAbBaseActivity{
      2. privatestaticfinalString TAG ="MainActivity";
      3. privateMyApplication myApplication;
      4. privateContext mContext;
      5. privateActionBar mActionBar;
      6. @Override
      7. protectedvoid onCreate(Bundle savedInstanceState){
      8. super.onCreate(savedInstanceState);
      9. setContentView(R.layout.sliding_menu_content);
      10. myApplication =(MyApplication) getApplication();
      11. mContext =this;
      12. mActionBar = getSupportActionBar();
      13. View actionbarView =LayoutInflater.from(this).inflate(R.layout.actionbar_layout,null);
      14. ActionBar.LayoutParams layoutParams =newActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
      15. ActionBar.LayoutParams.MATCH_PARENT);
      16. layoutParams.gravity =Gravity.CENTER_HORIZONTAL |Gravity.CENTER_HORIZONTAL;
      17. mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
      18. mActionBar.setDisplayShowHomeEnabled(false);
      19. mActionBar.setDisplayShowCustomEnabled(true);
      20. mActionBar.setDisplayShowTitleEnabled(false);
      21. mActionBar.setCustomView(actionbarView, layoutParams);
      22. Toolbar parent =(Toolbar) actionbarView.getParent();
      23. parent.setContentInsetsAbsolute(0,0);
      24. }
      25. }
       
       





    世界上没有什么事情是跑步解决不了的,如果有,那就再跑一会!
  • 相关阅读:
    NOI2018:屠龙勇士
    Hello world!
    bzoj5月月赛订正
    codeforces906 D
    bzoj2728 [HNOI2012]与非
    bzoj3884上帝与集合的正确用法
    bzoj2817[ZJOI2012]波浪
    2017多校联合赛1[题解]
    论如何优雅的用bitset来求四维偏序
    bzoj1488[HNOI2009]图的同构
  • 原文地址:https://www.cnblogs.com/his365/p/6078093.html
Copyright © 2011-2022 走看看