【发布时间】:2015-08-19 03:40:59
【问题描述】:
我有一些关于 android 工具栏的问题。通常,如果我在工具栏中设置自定义视图,该视图应该从左到右填充整个工具栏空间并且没有边距。
但我的左边有一个空白区域,这些是我的代码:
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/base_toolbar"
android:layout_width="match_parent"
android:layout_height="46dip"
android:background="?attr/colorPrimary" />
<FrameLayout
android:id="@+id/base_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
活动:
private void initToolbar() {
toolbar = (Toolbar) findViewById(R.id.base_toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if( actionBar != null)
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
contentLayout = (FrameLayout) findViewById(R.id.base_content);
}
我的代码有什么问题还是应该是这样的?
【问题讨论】:
标签: android toolbar android-custom-view