使用ViewPagerIndicator设置选项卡的文本大小不起作用

时间:2014-02-03 09:21:07

标签: android font-size android-tabs viewpagerindicator

在我的项目中,我有一个ViewPager没有链接到操作栏,我在设置选项卡文本的字体大小方面遇到了问题。我正在将ViewPagerIndicator(v2.4.1)与ActionBarSherlock(v4.3.1)结合使用。

我正在使用的布局是:

<com.viewpagerindicator.TabPageIndicator
    android:id="@+id/artistIndicator"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

<android.support.v4.view.ViewPager
    android:id="@+id/artistPager"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:minHeight="50dp" />

这位于LinearLayout内的ScrollView范围内。布局按预期工作,我发现ScrollView和我的ViewPager之间的互动没有任何问题。

使用以下XML完成ViewPager和制表符的样式设计:

<style name="ArtistIndicatorTheme" parent="AppTheme">
    <item name="vpiTabPageIndicatorStyle">@style/ArtistInfoTabPageIndicator</item>
</style>

<style name="ArtistInfoTabPageIndicator" parent="Widget.TabPageIndicator">
    <item name="android:background">@drawable/tab_background</item>
    <item name="background">@android:color/white</item>
    <item name="android:textAppearance">@style/ArtistInfoTabPageIndicator.Text</item>
</style>

<style name="ArtistInfoTabPageIndicator.Text" parent="@style/TextAppearance.TabPageIndicator">
    <item name="android:textColor">@drawable/tab_text_color</item>
    <item name="android:textSize">@dimen/activity_position_artistinfo_font_size</item>
    <item name="android:textStyle">bold</item>
</style>

选项卡的背景由以下XML处理,以创建实际的标签式外观:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_background_unselected" />
    <item android:state_focused="false" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/tab_background_selected" />
    <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_background_unselected" />
    <item android:state_focused="true" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/tab_background_selected" />
</selector>

这两个形状选择的XML:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- Bottom Line -->
    <item>
        <shape android:shape="rectangle" >
            <solid android:color="@color/text_inverted" />
        </shape>
    </item>

    <!-- Color of your action bar -->
    <item android:bottom="2dip">
        <shape android:shape="rectangle" >
            <solid android:color="@color/text_inverted" />
        </shape>
    </item>

</layer-list>

并取消选择:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- Bottom Line -->
    <item>
        <shape android:shape="rectangle" >
            <solid android:color="@color/text_inverted" />
        </shape>
    </item>

    <!-- Color of your action bar -->
    <item android:bottom="2dip" android:right="2dip">
        <shape android:shape="rectangle" >
            <solid android:color="@color/text_important" />
        </shape>
    </item>

</layer-list>

当前字体大小由以下维度设置:

<dimen name="activity_position_artistinfo_font_size">15dp</dimen>

关于我做错什么的任何迹象?

0 个答案:

没有答案