自定义动作条选项卡支持的填充 [英] Customize Padding of ActionBar Tabs Support
问题描述
我要删除的动作条的标签之间的填充(空格)。
I want to remove the padding (spaces) between the tabs of the ActionBar.
我使用的是Android的支持库V7(Appcompat)使用碎片和动作条中的Android 2.2 API 8为minSDK和4.4 API 19 maxSDK。
I am using the Android Support Library V7 (Appcompat) to use Fragments and the ActionBar in Android 2.2 API 8 as minSDK and 4.4 API 19 as maxSDK.
我曾尝试以下,但它不会改变任何东西。
I have tried the following but it does not change anything.
我的 styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
<item name="@style/Widget.AppCompat.ActionBar.TabView">@style/TabBarStyle</item>
</style>
<style name="TabBarStyle" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingRight">2dp</item>
</style>
</resources>
我从的AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:uiOptions="splitActionBarWhenNarrow" >
有人能告诉我请了如何扩展和正确使用自定义主题。
Can someone show me please how to extend and use the custom theme correctly.
推荐答案
配置的AndroidManifest.xml
来使用自定义主题:
configure your AndroidManifest.xml
to use a custom Theme:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
....
<application
...
android:theme="@style/AppTheme"
...
>
...
</application>
....
</manifest>
定义自定义主题的 RES /价值/
风格
的.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Use a custom Application theme extending an existing AppCompat theme. -->
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
</style>
<!-- customize parts of your theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- indicate that the actionBar uses a custom style and configure the link -->
<item name="actionBarTabStyle">@style/TabBarStyle</item>
</style>
<!-- configure your real custom style for the tab bar-->
<style name="TabBarStyle" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:paddingLeft">5dp</item>
<item name="android:paddingRight">5dp</item>
<item name="android:minWidth">10dp</item>
<item name="android:maxWidth">15dp</item>
</style>
</resources>
下面应放置在 RES /价值/
风格-V11
< $ C C>的.xml 和 RES /价值/
风格-V14
的.xml
<style name="AppTheme" parent="AppBaseTheme">
<item name="actionBarTabStyle">@style/TabBarStyle</item>
</style>
<style name="TabBarStyle" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:paddingLeft">5dp</item>
<item name="android:paddingRight">5dp</item>
<item name="android:minWidth">10dp</item>
<item name="android:maxWidth">15dp</item>
</style>
这篇关于自定义动作条选项卡支持的填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!