1

私はアンドロイドが初めてです。アプリの背景を白にしたかったので、アプリテーマのスタイルファイルで指定しました。しかし、そうすると、アプリのタブ レイアウトとメニュー項目の背景も白に変わったことがわかりました。どうすればいいのかわかりません。解決策を見つけようとしましたが、見つかりませんでした。

スタイル.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:background">@color/white</item>
    </style>

</resources>

activity_main.xml

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

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

<!-- THIS IS THE VIEW PAGER WIDGET, WHICH IS BASICALLY A CONTAINER OR PARENT FOR FRAGMENTS.
     IT GETS ITS SUPPLIES FROM PAGER ADAPTER. :) -->
<android.support.v4.view.ViewPager
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:id="@+id/viewpager">

    <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        app:tabBackground="@color/colorPrimary">

        <android.support.design.widget.TabItem
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="@string/tab_stock"/>

        <android.support.design.widget.TabItem
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="@string/tab_sale"/>

        <android.support.design.widget.TabItem
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="@string/tab_purchase"/>

    </android.support.design.widget.TabLayout>

</android.support.v4.view.ViewPager>

</LinearLayout>

色.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#008577</color>
    <color name="colorPrimaryDark">#00574B</color>
    <color name="colorAccent">#D81B60</color>
    <color name="white">#ffffff</color>

    <!-- COLOR FOR STOCK FRAGMENT' SUB HEADINGS -->
    <color name="colorSubHeading">#03A9F4</color>
    <color name="black">#000000</color>

</resources>

最後に、アクション バーを削除し、代わりにツールバーを使用したことをお伝えしたいと思います。前もって感謝します。

4

1 に答える 1