Android 工具栏没有';不要触摸屏幕的两侧

Android 工具栏没有';不要触摸屏幕的两侧,android,toolbar,Android,Toolbar,我正在尝试将工具栏添加到我的活动中,但我得到的只是以下内容: 为什么我的工具栏没有触及屏幕的边缘?这是我的布局代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_he

我正在尝试将工具栏添加到我的活动中,但我得到的只是以下内容:

为什么我的工具栏没有触及屏幕的边缘?这是我的布局代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"  
    tools:context=".EkranGlowny">


<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:minHeight="?attr/actionBarSize"
    android:background="#2196F3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

</android.support.v7.widget.Toolbar>


您正在对创建行为的
RelativeLayout
应用填充

除去

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"

从您的
RelativeLayout

中,您需要删除以下行以触摸屏幕的侧面:

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
然后,删除此行以触摸状态栏(橙色线):

我也建议删除这一行:

android:paddingBottom="@dimen/activity_vertical_margin"  
您可以为最后一个元素添加边距,如下所示:

android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"