ข้อผิดพลาดของ Android - ล้มเหลวในการค้นหาสไตล์ 'toolbarStyle' ในธีมปัจจุบัน

ฉันยังใหม่กับการเขียนโปรแกรม Android กำลังติดตามซีรีส์วิดีโอ YouTube ในปัจจุบัน (https://www.youtube.com/watch?v=Bzh9P1z1l90&list=PLshdtb5UWjSoLy2LPP1FsHi1hwoAS4SBi&index=7) เพื่อทำความเข้าใจวิธีทำงานกับดีไซน์ Material

ตอนนี้ผมติดอยู่จุดหนึ่งแล้ว ฉันได้รับข้อผิดพลาดเช่นนี้ ..

ป้อนคำอธิบายรูปภาพที่นี่

ฉันค้นหาใน Google ด้วย แต่ไม่ได้รับคำตอบที่เชื่อถือได้ นี่คือไฟล์ทั้งหมดของฉัน

styles.xml

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

    <style name="BhramaanTheme" parent="AppTheme"></style>

</resources>

v21/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="BhramaanTheme" parent="AppTheme">
        <item name="android:windowBackground">@color/windowBackground</item>
        <item name="android:navigationBarColor">@color/navigationBarColor</item>
    </style>
</resources>

activity_login.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"
    tools:context="com.bhramaan.android.bhramaan.LoginActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/tool_bar"
        />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/toolbar"
        android:text="Hello World!" />
</RelativeLayout>

tool_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark"
    >

</android.support.v7.widget.Toolbar>

AndroidMainfest.xml

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

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

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

</manifest>

LoginActivity.java

package com.bhramaan.android.bhramaan;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;

public class LoginActivity extends AppCompatActivity {

    Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }
}

ใครช่วยฉันให้เข้าใจว่าฉันทำอะไรผิดที่นี่?

ความนับถือ


person Suresh    schedule 12.08.2016    source แหล่งที่มา
comment
คุณไม่ได้กำหนดธีม ThemeOverlay.AppCompat.Dark ในไฟล์ style.xml   -  person Vinothkumar Nataraj    schedule 12.08.2016
comment
@ vinoth12594 : ขอบคุณสำหรับการตอบกลับอย่างรวดเร็ว คุณช่วยฉันเข้าใจวิธีกำหนดสิ่งนั้นได้ไหม จะแทนที่บรรทัดนี้ <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> ด้วย <style name="AppTheme" parent="ThemeOverlay.AppCompat.Dark"> หรือไม่   -  person Suresh    schedule 12.08.2016
comment
ระดับ API จำลองของคุณ???   -  person Vinothkumar Nataraj    schedule 13.08.2016
comment
ในหน้าต่างแสดงตัวอย่าง ให้เลือก AppTheme ของคุณในแถบด้านบน   -  person Mohammad Ersan    schedule 27.10.2016


คำตอบ (2)


ฉันคิดว่าคุณต้องใช้ ThemeOverlay.AppCompat.Dark.ActionBar เป็น themeOverlay บนแถบเครื่องมือของคุณแทน

person MrWasdennnoch    schedule 16.08.2016
comment
ฉันควรจะทำเช่นนั้นได้อย่างไร? - person Shariq Musharaf; 22.01.2017

แทนที่โค้ดด้านล่าง

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
          package="com.bhramaan.android.bhramaan">
    <application
        android:allowBackup="true" 
        android:icon="@mipmap/ic_launcher" 
        android:label="@string/app_name" 
        android:supportsRtl="true" 
        android:theme="@style/BhramaanTheme"> 
        <activity android:name=".LoginActivity"> 
            <intent-filter> 
                <action android:name="android.intent.action.MAIN" /> 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter> 
        </activity> 
    </application> 
</manifest>
person Vinothkumar Nataraj    schedule 13.08.2016