【问题标题】:How to customize Sliding tab viewpager in android如何在android中自定义滑动标签viewpager
【发布时间】:2014-08-25 05:33:49
【问题描述】:

我正在开发一个 android 应用程序,它使用 Tabs.(i.e).Sliding Tabs 的滑动 Viewpager。
我使用了来自https://github.com/vgrec/SlidingMenuWithViewpager的代码。
它运作良好。 现在我想自定义标签下划线/标签背景颜色。
我的屏幕截图如下所示。 我该怎么做?谢谢。

【问题讨论】:

  • 为每个选项卡使用自定义 xml 文件,扩充此 xml 文件并设置选项卡指示器,即 setIndicator(您的 xml 文件视图)...

标签: android android-tabs


【解决方案1】:

试试这个:

用这个替换你的 left_menu.xml 文件的内容

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/left_menu"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#CCC"
    android:orientation="vertical" xmlns:app="http://schemas.android.com/apk/res/org.grec">

    <com.astuetz.viewpager.extensions.PagerSlidingTabStrip
        android:id="@+id/tabs"
        app:shouldExpand="true"
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_height="48dip"
        android:background="#00FF00"
app:indicatorColor="#FF0000"
app:underlineColor="#F6CECE" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/tabs" />

</RelativeLayout>  

我已经测试过了,请看快照:

【讨论】:

    【解决方案2】:

    在 xml 文件 left_menu.xml 中添加这些文件。要更改颜色,请添加您自己的颜色代码。

    <com.astuetz.viewpager.extensions.PagerSlidingTabStrip
    android:background="#fff"
    app:indicatorColor="#BDBDBD"
    app:underlineColor="#F6CECE" .../>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多