我能够通过自定义我的应用程序主题来居中对齐操作栏
在我的AndroidManifest.xml中,我添加了一个android:theme属性:
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/CustomActionBarTheme">
...
Run Code Online (Sandbox Code Playgroud)
然后我在我的项目中添加了一个新的themes.xml文件,并添加了:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarTabBarStyle">@style/MyActionBarTabBar</item>
</style>
<style name="MyActionBarTabBar">
<item name="android:gravity">center</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
标签现在应该居中对齐.
编辑:仅当您的操作栏显示在2行(纵向)时才有效
| 归档时间: |
|
| 查看次数: |
3597 次 |
| 最近记录: |