Java 二进制XML文件行#73:膨胀类按钮时出错
这个问题一直困扰着我,我不完全确定是什么原因造成的。如果能提供任何帮助,我将不胜感激Java 二进制XML文件行#73:膨胀类按钮时出错,java,android,xml,Java,Android,Xml,这个问题一直困扰着我,我不完全确定是什么原因造成的。如果能提供任何帮助,我将不胜感激 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tencil/com.example.tencil.login}: android.view.InflateException: Binary XML file line #73 in com.example.tencil:layout/activity
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tencil/com.example.tencil.login}: android.view.InflateException: Binary XML file line #73 in com.example.tencil:layout/activity_login: Binary XML file line #73 in com.example.tencil:layout/activity_login: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #73 in com.example.tencil:layout/activity_login: Binary XML file line #73 in com.example.tencil:layout/activity_login: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #73 in com.example.tencil:layout/activity_login: Error inflating class Button
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_marginRight="20dp"
android:backgroundTint="#14b9d5"
android:fontFamily="@font/roboto_regular"
android:text="@string/login"
android:textColor="@android:color/white" />
<!-- android:background="@drawable/btn_custom"-->
现在,我已经在谷歌上搜索了无数次这个问题,我看不出哪里出了问题,任何帮助都将不胜感激
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tencil/com.example.tencil.login}: android.view.InflateException: Binary XML file line #73 in com.example.tencil:layout/activity_login: Binary XML file line #73 in com.example.tencil:layout/activity_login: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #73 in com.example.tencil:layout/activity_login: Binary XML file line #73 in com.example.tencil:layout/activity_login: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #73 in com.example.tencil:layout/activity_login: Error inflating class Button
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_marginRight="20dp"
android:backgroundTint="#14b9d5"
android:fontFamily="@font/roboto_regular"
android:text="@string/login"
android:textColor="@android:color/white" />
<!-- android:background="@drawable/btn_custom"-->
我现在遇到了这个问题:原因:java.lang.IllegalStateException:您需要在这个活动中使用一个Theme.AppCompat主题(或后代)
enter code here
您可以尝试创建一个样式文件并覆盖主题,以查看它是否更改了某些内容,这样您就可以知道是您的android设置弄乱了还是您的代码。your root styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" tools:override="true">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
您的AndroidManifest.xml
<application
android:name="YOUR APPLICATION NAME OR DELETE"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher_2"
android:theme="@style/AppTheme">
这会有用的。我希望这会有所帮助
主题修复。转到res/values/styles.xml,确保name=“AppTheme”的样式的父级为“Theme.AppCompat”
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
真的
假的
真的
@空的
如果您使用不同的样式,它的父级也必须是“Theme.AppCompat”,如下所示
真的
假的
真的
@空的
检查AndroidManifest.xml并查找活动。确保它引用了具有“Theme.AppCompat”父级的样式,如下所示
此组件上的样式要求您的应用程序主题为theme.AppCompat(或子代)。
嘿,团队,我现在遇到了这个问题:原因:java.lang.IllegalStateException:您需要在此活动中使用theme.AppCompat主题(或子代)。任何这样的想法都不能回答这个问题。若要评论或要求作者澄清,请在其帖子下方留下评论。-我对我提供的答案做了一些修改。希望能有帮助。但是说真的,在xml“android:layout_below=“@id/password”中的“@”之后添加“+”,使其成为“android:layout_below=“@+id/password”。嘿,团队,我现在遇到了这个问题:原因:java.lang.IllegalStateException:您需要使用一个Theme.AppCompat主题(或后代)有了这个活动。嘿,团队,我现在有了这个问题:原因:java.lang.IllegalStateException:你需要在这个活动中使用一个Theme.AppCompat主题(或子代)。这个问题解决了!!!
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<activity
android:name=".Activities.MyActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" />