我将v7 appcompat库升级到25.0.0,这导致我的活动突然在左边有这个奇怪的填充或边距:
我的活动扩展了AppCompatActivity,这里有一点点视图xml(activity_main.xml):
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="300dp"
android:layout_height="match_parent"
android:background="?attr/backgroundColorPrimary"
android:layout_gravity="start"
app:itemBackground="?attr/backgroundColorPrimary"
app:itemIconTint="?attr/foregroundColorPrimary"
android:fitsSystemWindows="false"
app:itemTextColor="?attr/foregroundColorPrimary">
<include layout="@layout/nav_side_bar"/>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
我已尝试将整个布局整理到CoordinatorLayout
并将contentInsetLeft
和contentInsetRight
设置为0dp,但仍然没有运气......我的Pixel似乎只发生了手机运行API 25(不是XL虽然)
答案 0 :(得分:0)
像这种标准格式一样使用。这应该适合你。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/root">
-----------------------------------------
-----PUT YOUR ADDITIONAL LAYOUT HERE-----
-----------------------------------------
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.CoordinatorLayout>