ActionBar with custom layout does not occupy full screen width on Android 4.4.2 (KitKat)

前端 未结 2 1162
遇见更好的自我
遇见更好的自我 2021-01-13 05:19

I want to display an Action Bar with a custom layout. The custom layout has three ImageViews, one in the centre and the other two on the left & right ends of the action

2条回答
  •  攒了一身酷
    2021-01-13 05:46

    In my case I have solved the issue bypassing the invocation of the LayoutInflater.

    So one should simply replace this code:

    View actionBarView = LayoutInflater.from(this).inflate(R.layout.custom_actionbar, null); 
    actionBar.setCustomView(actionBarView, lp);
    

    with this code:

    actionBar.setCustomView(R.layout.custom_actionbar);
    

提交回复
热议问题