iewpagerindicator&放TitlePageIndi

iewpagerindicator&放TitlePageIndi

本文介绍了分频器不工作与viewpagerindicator&放TitlePageIndicator; actionbarsherlock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到ViewPagerIndicator的最新版本,ICS风格的隔板都支持,我试图按照问题和解决方案,但无论我做什么我不能得到分频器对我的选择出现在动作条的该TitlePageIndicator。我加了IcsLayout作为容器,把护栏,showDividers和其他属性,但我仍然得到什么。这里是我的布局(奇怪的是,如果我切换IcsLayout到viewpager指标之一,应用程序崩溃):

 < com.actionbarsherlock.internal.widget.IcsLinearLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:程序=htt​​p://schemas.android.com/apk/res/com.sosick.android.brink
    机器人:layout_width =match_parent
    机器人:分=#FFFFFF
    机器人:showDividers =中间
    机器人:dividerPadding =8DP
    机器人:dividerHeight =10dp
    机器人:layout_height =match_parent
    机器人:方向=垂直>    < com.viewpagerindicator.TitlePageIndicator
        机器人:ID =@ + ID / tpi_header
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        文字颜色=@彩色/ text_light
        机器人:背景=@绘制/ ab_stacked_solid_brink
        应用:topPadding =10dp
        应用:footerPadding =15dp
        应用:footerColor =#a4ded7
        应用:footerIndicatorHeight =2DP
        应用:footerIndicatorStyle =下划线
        应用:footerLineHeight =2DP
        应用:selectedBold =FALSE/>    < android.support.v4.view.ViewPager
        机器人:ID =@ + ID / vp_pages
        机器人:layout_width =match_parent
        机器人:layout_height =0dp
        机器人:layout_weight =1/>< /com.actionbarsherlock.internal.widget.IcsLinearLayout>


解决方案

您需要的款式申报分PARAMS,而不是在布局XML。

../ RES /价值/ styles.xml:

 <样式名称=StyledIndicators父=@安卓风格/ Theme.Light>
    <项目名称=vpiIconPageIndicatorStyle> @风格/ CustomIconIndicator< /项目>
< /风格><样式名称=CustomIconIndicator父=Widget.TabPageIndicator>
    <项目名称=机器人:分> @绘制/ custom_tab_indicator_divider< /项目>
    <项目名称=机器人:showDividers>中< /项目>
    <项目名称=机器人:dividerPadding> 10dp< /项目>
< /风格>

在清单您的活动:

 <活动
        机器人:名字=。SampleIconsDefault
        机器人:标签=图标/默认
        机器人:主题=@风格/ StyledIndicators>
< /活性GT;

I noticed with the latest version of ViewPagerIndicator, ICS style dividers are supported, I tried to follow the issue and solution, but no matter what I do I can't get the divider to show up on my options on the actionbar for the TitlePageIndicator. I added the IcsLayout as the container, put divider, showDividers, and other properties, but am still getting nothing. Here's my layout (oddly enough, if I switch the IcsLayout to the viewpager indicator one, the app crashes):

<com.actionbarsherlock.internal.widget.IcsLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.sosick.android.brink"
    android:layout_width="match_parent"
    android:divider="#ffffff"
    android:showDividers="middle"
    android:dividerPadding="8dp"
    android:dividerHeight="10dp"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.viewpagerindicator.TitlePageIndicator
        android:id="@+id/tpi_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        textColor="@color/text_light"
        android:background="@drawable/ab_stacked_solid_brink"
        app:topPadding="10dp"
        app:footerPadding="15dp"
        app:footerColor="#a4ded7"
        app:footerIndicatorHeight="2dp"
        app:footerIndicatorStyle="underline"
        app:footerLineHeight="2dp"
        app:selectedBold="false" />

    <android.support.v4.view.ViewPager
        android:id="@+id/vp_pages"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

</com.actionbarsherlock.internal.widget.IcsLinearLayout>
解决方案

You need to declare divider params in styles, rather than in layout xml.

../res/values/styles.xml:

<style name="StyledIndicators" parent="@android:style/Theme.Light">
    <item name="vpiIconPageIndicatorStyle">@style/CustomIconIndicator</item>
</style>

<style name="CustomIconIndicator" parent="Widget.TabPageIndicator">
    <item name="android:divider">@drawable/custom_tab_indicator_divider</item>
    <item name="android:showDividers">middle</item>
    <item name="android:dividerPadding">10dp</item>
</style>

In manifest for your activity:

<activity
        android:name=".SampleIconsDefault"
        android:label="Icons/Default"
        android:theme="@style/StyledIndicators">
</activity>

这篇关于分频器不工作与viewpagerindicator&放TitlePageIndicator; actionbarsherlock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:51