gpt4 book ai didi

android - 如何使操作栏选项卡在 Android 中居中对齐?

转载 作者:太空狗 更新时间:2023-10-29 16:38:15 24 4
gpt4 key购买 nike

Android 操作栏选项卡默认左对齐,我想将它对齐到操作栏的中心。有什么方法可以让它居中吗?

最佳答案

通过自定义我的应用程序主题,我能够将操作栏居中对齐

在我的 AndroidManifest.xml 中,我添加了一个 android:theme 属性:

<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/CustomActionBarTheme">
...

然后我将一个新的 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>

标签现在应该居中对齐。

编辑:仅当您的操作栏显示在 2 行(纵向)上时才有效

关于android - 如何使操作栏选项卡在 Android 中居中对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22910212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com