【Android】ToolBar去除左边空白问题

  • 以下设置无效

<item name="contentInsetStart">0dp</item>
  • 增加或修改为

<item name="contentInsetStartWithNavigation">0dp</item>

 

 修改方法:

1、在styles.xml的BaseTheme或对应的Activity Theme中增加

<item name="contentInsetStartWithNavigation">0dp</item>

 

2、在对应布局文件中的toolbar增加

<androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/white"
            app:layout_scrollFlags="scroll"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            app:title="我是标题"
            app:contentInsetStartWithNavigation="0dp"
            app:titleTextColor="@color/text_black" />

 

posted @ 2020-03-28 14:39  流浪的青蛙_Zzz  阅读(635)  评论(0)    收藏  举报