ActionBar和标签未正确显示

时间:2016-10-08 16:42:00

标签: android android-layout android-studio android-actionbar android-xml

This是我的应用显示的内容

您可以看到顶部的操作栏和标签布局都是白色的。由于某种原因,他们被设置为我的颜色backgroundColor。我希望将它们设置为primaryColor。我该怎么做?

这是我的代码:

主xml布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.mddri_.myeats.main._MainActivity">



<android.support.design.widget.TabLayout
    android:id="@+id/tab_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:tabMode="scrollable"
    android:background="@color/colorPrimary"
    />
<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/tab_layout"/>

清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mddri_.myeats">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <meta-data
        android:name="android.app.searchable"
        android:resource="@xml/searchable" />

    <activity android:name=".main.MainActivity">

    </activity>
    <activity android:name=".viewdatabase.ViewDatabase">
        <meta-data
            android:name="android.app.searchable"
            android:resource="@xml/searchable" />
    </activity>
    <activity android:name=".viewmeals.ViewMeals" />
    <activity android:name=".viewkitchen.ViewKitchen" />
    <activity
        android:name=".main._MainActivity"
        android:label="@string/title_activity___main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

样式:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat"> <!--.Light.DarkActionBar-->
    <!-- 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/background</item>
    <item name="android:textColor">@color/textColor</item>
    <item name="android:editTextColor">@color/textColor</item>
    <item name="android:actionBarStyle">@style/ActionBarTheme</item>
</style>
<style name="ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
    <item name="android:background">@color/colorPrimary</item>
</style>

颜色

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#C0FF3E</color>
<color name="colorPrimaryDark">#04a314</color>
<color name="colorAccent">#8a9b8c</color>
<color name="textColor">#555555</color>
<color name="background">#fcfcfc</color>
</resources>

有人可以帮我弄清楚我做错了什么吗?我将actionbar和tablayout的背景颜色设置为colorPrimary,但它仍然显示为colorbackground

0 个答案:

没有答案