android.support.v7.widget.Toolbar图标排列问题 [英] android.support.v7.widget.Toolbar icon alignment issue
问题描述
使用全新的Android 5.0工具栏的方法,并按照谷歌IO的例子,我设置一个导航图标和工具栏上的一个微调。
问题是,导航图标下对齐。我找不到任何理由为什么会这样...
[注意,我故意将其设置为一个坚实的方形看到对齐问题更加清晰]
我的code是如下:
toolbar.xml
< android.support.v7.widget.Toolbar
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
应用程序:主题=@风格/ ActionBarThemeOverlay
应用程序:popupTheme =@风格/ ActionBarPopupThemeOverlay
机器人:ID =@ + ID / toolbar_actionbar
机器人:layout_width =match_parent
机器人:机器人:actionBarSizelayout_height =
/>
主要风格
<样式名称=ActionBarThemeOverlay父=>
<项目名称=机器人:背景> @色/ appMainColor< /项目>
<项目名称=机器人:textColorPrimary>#FFF< /项目>
<项目名称=colorControlNormal>#FFFF< /项目>
<项目名称=colorControlHighlight>#3FFF< /项目>
< /风格>
ActivityMain
getSupportActionBar()setDisplayHomeAsUpEnabled(真)。
如果(mActionBarToolbar!= NULL)
mActionBarToolbar.setNavigationIcon(R.drawable.ic_drawer);
尝试使用的 ATTR / actionBarSize 的而不是安卓?layout_height =机器人:actionBarSize的
< android.support.v7.widget.Toolbar
机器人:layout_height =?ATTR / actionBarSize>
Using the new Android 5.0 Toolbar approach, and following the Google IO example, I'm setting a navigation icon and a spinner in the toolbar.
The issue is, the navigation icon is BOTTOM-aligned. I can't find any reason why this is happening...
[Note that I deliberately set it to a solid square to see the alignment issue more clearly]
My code is as follows:
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:theme="@style/ActionBarThemeOverlay"
app:popupTheme="@style/ActionBarPopupThemeOverlay"
android:id="@+id/toolbar_actionbar"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
/>
Main Style
<style name="ActionBarThemeOverlay" parent="">
<item name="android:background">@color/appMainColor</item>
<item name="android:textColorPrimary">#fff</item>
<item name="colorControlNormal">#ffff</item>
<item name="colorControlHighlight">#3fff</item>
</style>
ActivityMain
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (mActionBarToolbar != null)
mActionBarToolbar.setNavigationIcon(R.drawable.ic_drawer);
Try to use ?attr/actionBarSize instead of android:layout_height="?android:actionBarSize"
<android.support.v7.widget.Toolbar
android:layout_height="?attr/actionBarSize">
这篇关于android.support.v7.widget.Toolbar图标排列问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!