ViewPagerIndicator:选项卡标题是否支持多行文本?

5

我正在尝试在ViewPagerIndicator中使用"Sample Styled Tabs"示例,将选项卡文本显示为两行。目前我已经做了以下工作:

  • In SampleTabsStyled.java, I made the following change to GoogleMusicAdapter. Notice the new line character I added to the title string:

    @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();
    }
    
  • In styles.xml, I made the following change:

    <style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
        <item name="android:typeface">monospace</item>
        <item name="android:singleLine">false</item>
    </style>
    

然而,在VPI标签中我只看到第一行文字,而没有看到第二行数字。我可能做错了什么?

1个回答

6

在G+的帮助下,我找到了答案。这就是我需要做的:

  • Don't bother with modifying the style for CustomTabPageIndicator.Text. I reverted it to the original.
  • Add the following line to the style for CustomTabPageIndicator:

    <item name="android:maxLines">2</item> 
    
那对我来说就行了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接