如何去除Android Toolbar的左边距?
如何去除Android Toolbar的左边距?
我正在尝试在我的项目中使用工具栏。
以下是我正在使用的代码:
android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:layout_alignParentTop="true" android:background="?attr/colorPrimary" android:contentInsetLeft="0dp" android:elevation="@dimen/margin_padding_8dp" android:contentInsetStart="0dp"> android:id="@+id/rlToolbar" android:layout_width="match_parent" android:layout_height="match_parent"> android:id="@+id/tvTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:paddingRight="@dimen/margin_padding_16dp" android:text="AppBar" android:textAppearance="@style/TextAppearance.AppCompat" android:textColor="@color/white" android:textSize="@dimen/text_size_20sp" />
我想去掉左边的边距,我设置了android:contentInsetLeft="0dp"和android:contentInsetStart="0dp",但是它不起作用..请帮帮我!
在Android的工具栏(Toolbar)上去除左边距的方法是在XML布局文件中添加app:contentInsetStart="0dp"
这一行代码。这是因为在API 21之前(即Android Lollipop之前),需要添加这一行代码。
具体代码如下:
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="64dp" android:background="/colorPrimary" android:minHeight="?attr/actionBarSize" android:contentInsetStart="0dp" app:contentInsetStart="0dp" > </android.support.v7.widget.Toolbar>