操作栏左侧的额外边距

时间:2015-07-13 12:04:41

标签: android android-actionbar android-actionbaractivity

我是Android的新手,在我的第一个应用程序上工作。我遇到了问题,当我在API 18及更高版本上运行我的应用程序时,我在操作栏中看到额外的保证金。

我用Google搜索并找到了这个答案: -  Android: remove left margin from actionbar's custom layout

但我不认为这适用于我, 首先,(根据上面链接中建议的解决方案) 1)我没有使用工具栏,而是使用操作栏 2)Android Studio为以下代码抛出错误

        Toolbar parent =(Toolbar) customView.getParent();
        parent.setContentInsetsAbsolute(0,0);

说,最小值为14,setContentInsetsAbsolute需要API 21。 所以我这样做了,

 if(Build.VERSION.SDK_INT == 21 ){
        Toolbar parent =(Toolbar) customView.getParent();
        parent.setContentInsetsAbsolute(0,0);
 }

但这没有帮助。 我哪里出错了以及如何解决这个问题?

0 个答案:

没有答案
相关问题