【发布时间】:2017-02-22 03:06:12
【问题描述】:
我设置的工具栏布局 android:layout_gravity="center_vertical" 但它不起作用
代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/toolbar_bg"
android:fitsSystemWindows="true"
app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@android:drawable/sym_def_app_icon" />
主要布局:
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/head_tool_bar"
layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/head_tool_bar" />
</RelativeLayout>
<!-- The drawer is given a fixed width in dp and extends the full height of
the container. -->
<fragment
android:id="@+id/navigation_drawer"
android:name="com.voogolf.helper.home.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
tools:layout="@layout/drawer_new_home" />
</android.support.v4.widget.DrawerLayout>
如何设置抽屉图标和徽标顶部对齐?为什么左侧抽屉图标有填充 像这样?
【问题讨论】:
-
这里面的imageview是什么?
-
如果您将这些项目添加到工具栏中的相对或线性布局中会更好。
-
我在toolbar中删除了我的自定义imageview,以及toolbar.setLogo(),但是结果和上图一样,不能algin左边的drawer icon,为什么?
标签: android toolbar statusbar android-appcompat