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. }
       
       





    世界上没有什么事情是跑步解决不了的,如果有,那就再跑一会!
  • 相关阅读:
    CF1416D Graph and Queries
    Wordpress建站系统相关
    微观经济学
    Preface
    Thread pool in chromium
    [fllutter engine] 并发消息队列
    bugku misc
    python 3.1学习
    HTML&CSS
    DOM技术点
  • 原文地址:https://www.cnblogs.com/his365/p/6078093.html
Copyright © 2011-2022 走看看