5

Я хочу удалить прописку (пробелы) между вкладками ActionBar.Customize Padding of ActionBar Tabs Support

Я использую библиотеку поддержки Android V7 (Appcompat) для использования фрагментов и ActionBar в Android 2.2 API 8 как minSDK и 4.4 API 19 как maxSDK.

Я пробовал следующее, но ничего не меняет.

Мой 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" > 

Может кто-то показать мне, пожалуйста, как продлить и правильно использовать собственную тему.

ответ

4

настроить AndroidManifest.xml использовать пользовательскую тему:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    .... 
    <application 
     ... 
     android:theme="@style/AppTheme" 
     ... 
    > 
    ... 
    </application> 
    .... 
</manifest> 

Определите собственную тему в res/values/styles.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/values/styles-v11.xml и res/values/styles-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> 

Смежные вопросы