Android 支持工具栏标题/菜单垂直中心
我是android开发的新手,正在开发一款带有ActionBar和Tabs的应用程序。最近,我切换到新的支持库Android 支持工具栏标题/菜单垂直中心,android,android-toolbar,Android,Android Toolbar,我是android开发的新手,正在开发一款带有ActionBar和Tabs的应用程序。最近,我切换到新的支持库工具栏,但工具栏(ActionBar)的标题没有垂直居中,而操作按钮的位置正确。 同样的问题也发生在工具栏中的第一个菜单项上(它稍微向上移动了一点) “我的活动”扩展了AppCompativety,布局如下所示: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.Coordina
工具栏,但工具栏(ActionBar)的标题没有垂直居中,而操作按钮的位置正确。
同样的问题也发生在工具栏中的第一个菜单项上(它稍微向上移动了一点)
“我的活动”扩展了AppCompativety,布局如下所示:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/action_bar_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ActionBarTheme"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed"/>
<com.myApp.app.views.widgets.ViewPager
android:id="@+id/fragmentPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"/>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
风格:
<style name="ActionBarTheme" parent="Widget.AppCompat.Toolbar">
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="colorControlNormal">@color/colorPrimaryDark</item>
<item name="android:background">@color/colorPrimary</item>
</style>
@颜色/原色暗
@颜色/原色暗
@颜色/原色
有人能帮我解决这个问题吗?我一直在寻找解决办法,但一无所获
注意,它们的位置正确,因为我使用的是默认的操作栏您应该使用android:theme
,而不是app:theme
,这里:
android:theme="@style/ActionBarTheme"
您的样式应源自动作栏覆盖:
<style name="ActionBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
...
</style>
...
考虑直接使用ActionBar主题来隔离问题