I have a Actionbar Tab with icon and text:

actionBar.addTab(actionBar.newTab()
              .setText("Tab1")
              .setIcon(R.drawable.image));

I want add a "10dp" padding between the icon and text of the tab and use "styles":

<item name="android:actionBarTabStyle">@style/MyTabStyle</item>

and

<style name="MyTabStyle" parent="AppTheme">
    <item name="android:paddingLeft">10dp</item>
    <item name="android:paddingRight">10dp</item>
</style>

Example:

(image)Tab1 --> (image)"10dp"Tab1

I solved momentarily with: .setText(" Tab1")

有帮助吗?

解决方案

Try with margin or layout_margin :

    <style name="MyTabStyle" parent="AppTheme">
        <item name="android:layout_marginLeft">10dp</item>
        <item name="android:layout_marginRight">10dp</item>
    </style>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top