2017-10-18 2 views
1

Ich bin neu in Android Studio. Mein Projekt wird ausgeführt und ausgeführt, aber jedes Mal, wenn ich auf activity_login.xml klicke, kann ich kein Element sehen, sondern nur ein einfaches Layout. Ich konnte die Texteingabe oder gar die Schaltfläche nicht sehen. Hier ist der Fehler, dass ich, wenn ich mein Layout-Vorschau:Rendering Probleme mit NoActionBar Theme. Die folgenden Klassen konnten nicht gefunden werden: android.support.v7.widget.AppCompatTextView

Rendering Problems The following classes could not be instantiated: 
- android.support.v7.widget.AppCompatTextView 

hier mein Layout ist:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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" 
android:gravity="center_horizontal" 
android:orientation="vertical" 
tools:context="com.example.myapp.mealplanner.LoginActivity"> 

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


<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="50dp" 
    android:paddingEnd="16dp" 
    android:paddingStart="16dp" 
    android:text="@string/login_statement" 
    android:textColor="@color/black" 
    android:textSize="18sp" 
    android:textStyle="bold" /> 


<android.support.design.widget.TextInputLayout 
    android:id="@+id/login_email" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="15dp" 
     android:hint="@string/enter_your_email" 
     android:inputType="textEmailAddress" /> 
</android.support.design.widget.TextInputLayout> 

<android.support.design.widget.TextInputLayout 
    android:id="@+id/login_password" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="15dp" 
     android:hint="@string/enter_your_password" 
     android:inputType="textPassword" /> 
</android.support.design.widget.TextInputLayout> 


<Button 
    android:id="@+id/login_login_btn" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="15dp" 
    android:text="@string/login" /> 

</LinearLayout> 

Hier ist meine App gradle:

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 26 
buildToolsVersion "26.0.0" 
defaultConfig { 
    applicationId "com.example.myapp.mealplanner" 
    minSdkVersion 19 
    targetSdkVersion 24 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner" 
    multiDexEnabled true 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro' 
    } 
} 
productFlavors { 
    } 
} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{ 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
//compile 'com.android.support:appcompat-v7:26.1.0' 
compile 'com.android.support:appcompat-v7:26.+' 
//compile 'com.android.support:design:26.+' 
compile 'com.android.support:design:26.1.0' 
compile 'com.google.firebase:firebase-database:11.4.2' 
compile 'com.google.firebase:firebase-core:11.4.2' 
compile 'com.google.firebase:firebase-auth:11.4.2' 
compile 'com.google.firebase:firebase-storage:11.4.2' 
compile 'com.firebaseui:firebase-ui-database:3.0.0' 
compile 'com.firebaseui:firebase-ui-auth:3.0.0' 
compile 'com.squareup.picasso:picasso:2.5.2' 
//compile 'com.android.support:recyclerview-v7:26.1.0' 
//compile 'com.android.support:cardview-v7:26.1.0' 
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1' 
compile 'com.android.support:cardview-v7:26.0.0-alpha1' 
compile 'com.android.support.constraint:constraint-layout:1.0.2' 
compile 'com.google.android.gms:play-services:11.4.2' 
compile 'com.google.firebase:firebase-core:11.4.2' 
compile 'com.android.support:multidex:1.0.1' 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:24.0.0' 
} 
apply plugin: 'com.google.gms.google-services' 

ich das Problem zu erraten von Gradle kommen, habe ich versucht, mein Android Studio zu aktualisieren, Invalidate Cache. Nichts davon funktioniert jedoch. Thema kann ein Problem sein, aber ich möchte "No Action Bar" Theme verwenden. Das ist meine style.xml Datei:

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

<style name="AppTheme.AppBarOverlay" 
parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

</resources> 

Bitte helfen Sie mir, die Probleme zu lösen. Danke im Voraus.

+0

Mögliche Duplikat von [Die folgenden Klassen konnten nicht instanziiert werden: - android.support.v7.widget.Toolbar] (https://StackOverflow.com/Questions/26575815/the-following-Classes -ould-not-instanziiert-android-support-v7-widget-too) –

Antwort

0

Es ist ein kleiner Fehler in appcompat v26.

In Ihrem styles.xml verwenden Sie Base.Theme.AppCompat anstelle von Theme.AppCompat als das übergeordnete Thema.

Anscheinend gibt es kein solches Thema für NoActionBar in Base. So ein Thema zu verwenden, wie unten:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 

    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 
+0

Base.Theme.AppCompat wird die Probleme lösen. Ich möchte jedoch No Action Bar verwenden, die Base.Theme.AppCompat.NoActionBar nicht vorhanden ist. – hjhk19

+0

Wenn ich versuche, es in Android Studio zu setzen, hieß es: Base.Theme.AppCompat.Light.NoActionBar kann nicht aufgelöst werden. mit der roten Farbe – hjhk19

Verwandte Themen