突出或强调所选TabPageIndicator

突出或强调所选TabPageIndicator

本文介绍了突出或强调所选TabPageIndicator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个平板电脑大小的景观布局dualpane和我使用的片段。

I have a dualpane on a tablet-sized landscape layout and I'm using fragments.

在左边我有一个列表视图的片段。当点击发生在项目列表中的一个合适的片段加载的细节。

On the left I have a fragment with a listview. When a click occurs on one of the item list the right fragment loads the detail.

在右侧(详细信息)片段的布局有一个 com.viewpagerindicator.TabPageIndicator android.support.v4.view。 ViewPager。该ViewPager将装载2个元素,每一个都有其 com.viewpagerindicator.TabPageIndicator 。我想突出或强调所选的选项卡,但我没有这样做。

In the layout of the right (detail) fragment there is a com.viewpagerindicator.TabPageIndicator and a android.support.v4.view.ViewPager.The ViewPager will load 2 elements and each one has its com.viewpagerindicator.TabPageIndicator.I'm trying to highlight or underline the selected tab but I failed doing it.

我希望你有一些建议:)

I hope you have some advice :)

推荐答案

默认情况下,TabPageIndicator不适用任何风格。从ViewPagerIndicator启用默认样式添加以下行无论是在应用程序标签或相应的活动标记的的manifest.xml

By default the TabPageIndicator doesn't apply any style. To enable the default style from ViewPagerIndicator add the following line to either the application tag or the appropriate activity tag in your manifest.xml

android:theme="@style/Theme.MyTheme"

然后添加一个水库\值\ styles.xml 文件与下面的内容你的项目

Then add a res\values\styles.xml file to your project with the following content

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.MyTheme" parent="@android:style/Theme.Light">
        <item name="vpiTabPageIndicatorStyle">@style/Widget.TabPageIndicator</item>
    </style>
</resources>

我使用的是Android的灯光主题为我的应用程序,但你可能想改变这个给你现在正在使用的主题。

I'm using the android light theme for my application, but you might want to change this to the theme you are using now.

如果你想更改默认VPI样式修改 styles.xml 文件来是这样的:

If you want to make changes to the default VPI style change the styles.xml file to something like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>

  <style name="Theme.MyTheme" parent="@android:style/Theme.Light">
    <item name="vpiTabPageIndicatorStyle">@style/MyTabPageIndicator</item>
  </style>

  <style name="MyTabPageIndicator" parent="Widget.TabPageIndicator">
    <item name="android:gravity">center</item>
    <item name="android:background">@drawable/vpi__tab_indicator</item>
    <item name="android:paddingLeft">22dip</item>
    <item name="android:paddingRight">22dip</item>
    <item name="android:paddingTop">12dp</item>
    <item name="android:paddingBottom">12dp</item>
    <item name="android:textAppearance">@style/MyTabPageIndicator.Text</item>
    <item name="android:textSize">12sp</item>
    <item name="android:maxLines">1</item>
  </style>

  <style name="MyTabPageIndicator.Text" parent="TextAppearance.TabPageIndicator">
    <item name="android:textStyle">bold</item>
    <item name="android:textColor">@color/vpi__dark_theme</item>
  </style>

</resources>

请注意,上述设置是完全一样的默认VPI样式为TabPageIndicactor,所以你还是得让你想更改。

Note that the settings above are exactly the same as the default VPI style for the TabPageIndicactor, so you still have to make the changes you'd like.

这篇关于突出或强调所选TabPageIndicator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 04:57