Android Material Design颜色未统一应用

时间:2017-12-06 17:51:52

标签: android xml kotlin

我的activity_main.xml包含我正在寻找的主题。某些活动(如activity_disaster.xml)具有部分应用程序,而一个activity_disaster_overview.xml没有任何内容,并且缺少操作栏。

AndroidManifest:

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
            android:theme="@style/IdleHands">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".DisasterActivity"
            android:theme="@style/IdleHands"/>
        <activity android:name=".LoggedInDisasterActivity"
            android:theme="@style/IdleHands"/>
        <activity android:name=".CreateDisasterActivity"
            android:theme="@style/IdleHands"/>
        <activity android:name=".DisasterOverviewActivity"
            android:theme="@style/IdleHands"></activity>
    </application>

</manifest>

styles.xml

    <!-- 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>
    </style>

    <style name="IdleHands" parent="AppTheme" >
        <item name="android:colorForeground">@color/foreground_material_light</item>
        <item name="android:navigationBarColor">@color/colorPrimaryDark</item>
    </style>

</resources>

working activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="org.sherman.magic.idlehands.MainActivity">

</android.support.constraint.ConstraintLayout>

不工作activity_disaster_overview.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="org.sherman.magic.idlehands.DisasterOverviewActivity">

</android.support.constraint.ConstraintLayout>

MainActivity Code:

package org.sherman.magic.idlehands

import android.support.v7.app.AppCompatActivity
import android.os.Bundle

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}

如何使它们与activity_main.xml匹配一致。而不是一堆混合的结果。

1 个答案:

答案 0 :(得分:0)

原来是Android工作室的一个版本。我升级到3.0.1,问题就消失了。