ViewPagerIndicator:标题标题的多行文字?

cur*_*zen 5 android viewpagerindicator

我正在尝试使用ViewPagerIndicator中的"Sample Styled Tabs"示例将标签文本显示为2行.这是我到目前为止所做的:

  • SampleTabsStyled.java,我做了以下更改GoogleMusicAdapter.注意我添加到标题字符串的新行字符:

    @Override
    public CharSequence getPageTitle(int position) {
        StringBuilder sb = new StringBuilder(CONTENT[position % CONTENT.length].toUpperCase());
        sb.append("\n");
        sb.append(RANDOM.nextInt(1000));
        return sb.toString();
    }
    
    Run Code Online (Sandbox Code Playgroud)
  • styles.xml,我做了以下改变:

    <style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
        <item name="android:typeface">monospace</item>
        <item name="android:singleLine">false</item>
    </style>
    
    Run Code Online (Sandbox Code Playgroud)

但是,我只看到VPI选项卡中的第一行文本.我没有看到第二行数字.我可能做错了什么?

cur*_*zen 6

我在G +的帮助下找到了答案.这就是我必须做的事情:

  • 不要为修改样式而烦恼CustomTabPageIndicator.Text.我将它恢复原状.
  • 将以下行添加到样式中CustomTabPageIndicator:

    <item name="android:maxLines">2</item> 
    
    Run Code Online (Sandbox Code Playgroud)

这样做对我来说.