工具栏布局我设置的android:layout_gravity = “center_vertical” ,但它不能正常工作Android的导航工具栏图标和标识不能对齐
代码:
<?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.setLogo()中删除了我的自定义图像视图,但结果与上面的图片相同,无法添加左侧抽屉图标,为什么? –