在Android Studio中应用主题后出现错误

在Android Studio中应用主题后出现错误,第1张

概述我是android工作室的新手.我几天前开始学习android.我从简单的空白活动开始,并从“新波士顿”教程中学习.尽管我在执行应用程序后立即应用了主题,但还是遇到了以下错误.STYLE.XML代码:<resources><!--Baseapplicationtheme.--><stylename="AppTheme"p

我是android工作室的新手.我几天前开始学习androID.我从简单的空白活动开始,并从“新波士顿”教程中学习.尽管我在执行应用程序后立即应用了主题,但还是遇到了以下错误.

STYLE.XML代码:

 <resources>        <!-- Base application theme. -->        <style name="Apptheme" parent="theme.AppCompat">            <!-- 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.NoActionbar">            <item name="windowActionbar">false</item>            <item name="windowNoTitle">true</item>        </style>        <style name="Apptheme.AppbarOverlay" parent="themeOverlay.AppCompat.Dark.Actionbar" />        <style name="Apptheme.PopupOverlay" parent="themeOverlay.AppCompat.light" />    </resources>

布局:主要活动代码:

<?xml version="1.0" enCoding="utf-8"?><androID.support.design.Widget.CoordinatorLayout 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="com.example.wardahamk.changingtheme.MainActivity">    <androID.support.design.Widget.AppbarLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:theme="@style/Apptheme.AppbarOverlay">    </androID.support.design.Widget.AppbarLayout>    <include layout="@layout/content_main"        androID:ID="@+ID/include" />    <androID.support.design.Widget.floatingActionbutton        androID:ID="@+ID/fab"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_gravity="bottom|end"        androID:layout_margin="@dimen/fab_margin"        app:srcCompat="@androID:drawable/ic_dialog_email" />    <button        androID:ID="@+ID/button"        androID:layout_wIDth="wrap_content"        androID:layout_height="0dp"        androID:text="button"        app:layout_anchor="@+ID/include" />    <androID.support.v7.Widget.Toolbar        androID:ID="@+ID/toolbar"        androID:layout_wIDth="match_parent"        androID:layout_height="?attr/actionbarSize"        androID:background="?attr/colorPrimary"        app:popuptheme="@style/Apptheme.PopupOverlay" /></androID.support.design.Widget.CoordinatorLayout>

布局:内容活动代码:

<?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"    app:layout_behavior="@string/appbar_scrolling_vIEw_behavior"    tools:context="com.example.wardahamk.changingtheme.MainActivity"    tools:showIn="@layout/activity_main">    <TextVIEw        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:text="Hello World!"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintleft_toleftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constrainttop_totopOf="parent" /></androID.support.constraint.ConstraintLayout>

Gradle脚本:build.gradle(项目:主题更改):

buildscript {        repositorIEs {            jcenter()        }        dependencIEs {            classpath 'com.androID.tools.build:gradle:2.3.2'            // NOTE: Do not place your application dependencIEs here; they belong            // in the indivIDual module build.gradle files        }    }    allprojects {        repositorIEs {            jcenter()        }    }    task clean(type: Delete) {        delete rootProject.buildDir    }

Gradle脚本:build.gradle(Module App)

apply plugin: 'com.androID.application'androID {    compileSdkVersion 25    buildToolsversion "25.0.3"    defaultConfig {        applicationID "com.example.wardahamk.changingtheme"        minSdkVersion 9        targetSdkVersion 25        versionCode 1        versionname "1.0"        testInstrumentationRunner "androID.support.test.runner.AndroIDJUnitRunner"    }    buildTypes {        release {            MinifyEnabled false            proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro'        }    }}dependencIEs {    compile filetree(dir: 'libs', include: ['*.jar'])    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:25.3.1'    compile 'com.androID.support.constraint:constraint-layout:1.0.2'    compile 'com.androID.support:design:25.3.1'    testCompile 'junit:junit:4.12'}

我一直在寻找解决方案,但无法解决.如果您能帮助我找出解决方案,我将非常感谢.多谢先进!

解决方法:

使用theme.AppCompat.light或theme.AppCompat.light.DarkActionbar主题.

总结

以上是内存溢出为你收集整理的在Android Studio中应用主题后出现错误全部内容,希望文章能够帮你解决在Android Studio中应用主题后出现错误所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1121070.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存