android - PagerTabStrip 标题背景色

标签 android colors background

我在 PagerTabStrip 中更改了背景颜色,但选项卡标题有白色背景

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<android.support.v4.view.PagerTabStrip
    android:id="@+id/pager_tab_strip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="#c9c9c9"
    android:padding="4dp"
    android:textColor="#000000"
    />

我在哪里更改它?

最佳答案

如果资源文件在 res/values/colors.xml 中不存在(对于颜色),则创建一个具有所需值的颜色的资源文件。

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

<resources>
    <color name="tabstrip_bg">#ff6d9850</color>
</resources>

在你的布局文件中(持有各自的 ViewPager 和 TabStrip)修改引用上面颜色的 android:background 参数,如下所示。

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

    <android.support.v4.view.PagerTabStrip
        android:id="@+id/pager_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:background="@color/tabstrip_bg" />
</android.support.v4.view.ViewPager>

关于android - PagerTabStrip 标题背景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17470194/

相关文章:

android - 我应该将 com.myapp.R 导入到我的 Activity 中吗?

javascript - 为什么我的 Nativescript-vue 发布 apk 出现错误

Facebook 喜欢框边框颜色

javascript - 将随机 css 颜色更改为一个 DIV 的背景和另一个 DIV 的边框顶部颜色

html - 使div背景与主体高度相同

html - 我可以用纯 css 创建交叉线背景框吗

android - Android Studio:Gradle Sync的v4支持库失败

android - 如何在不使用 SDK 的情况下将文件从 Android 上传到 Amazon S3

vim - 使用 Iterm2 在 Vim 中获取配色方案时遇到问题

r - R 中的二维颜色渐变图