Android 即使我指定了另一个主题,我的activity_main.xml仍然使用默认主题
即使我指定了另一个主题,我的activity_main.xml仍然使用默认主题。请在下面找到我的代码: 风格Android 即使我指定了另一个主题,我的activity_main.xml仍然使用默认主题,android,android-theme,Android,Android Theme,即使我指定了另一个主题,我的activity_main.xml仍然使用默认主题。请在下面找到我的代码: 风格 <resources> <!-- Launch screen --> <style name="LaunchScreenTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> &l
<resources>
<!-- Launch screen -->
<style name="LaunchScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
清单
<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">
...
...
活动\u main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
...
android:theme="@style/LaunchScreenTheme"
tools:context=".MainActivity">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/logo_orange"
/>
</LinearLayout>
即使我在上面设置了LaunchScreenTheme
,它仍然使用默认的AppTheme
想知道为什么吗?在
activity\u main.xml
中,尝试风格:“@style/LaunchScreenTheme”
而不是android:theme=“@style/LaunchScreenTheme”
在activity\u main.xml
中,尝试风格:“@style/LaunchScreenTheme”
而不是android:theme=“@style/LaunchScreenTheme”
如果您想专门为某个活动设置主题,那么您可以在清单中这样设置它-
<activity
android:name=".StartActivity"
android:theme="@style/LaunchScreenTheme" />
如果要为整个应用程序设置主题,则必须将其设置为清单-
<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/LaunchScreenTheme">
…如果您想专门为某个活动设置主题,那么您可以在清单中这样设置它-
<activity
android:name=".StartActivity"
android:theme="@style/LaunchScreenTheme" />
如果要为整个应用程序设置主题,则必须将其设置为清单-
<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/LaunchScreenTheme">
…尝试使用style
style=“@style/AppTheme”
而不是theme。如果要使用主题,请在清单文件中将其指定为
inline?我仍然希望AppTheme
成为默认值,但我希望activity_main.xml在清单中使用LaunchScreenTheme
,我告诉你要将主题设置为完美的活动,而不是应用程序标记。如果你想在xml中使用,那么在xml文件中指定它为styleJust tested settingsstyle=“@style/LaunchScreenTheme”
。它不起作用-仍然使用默认的AppTheme
尝试使用stylestyle=“@style/AppTheme”
而不是theme。如果要使用主题,请在清单文件中将其指定为
inline?我仍然希望AppTheme
成为默认值,但我希望activity_main.xml在清单中使用LaunchScreenTheme
,我告诉你要将主题设置为完美的活动,而不是应用程序标记。如果你想在xml中使用,那么在xml文件中指定它为styleJust tested settingsstyle=“@style/LaunchScreenTheme”
。它不起作用-仍然使用默认的AppTheme
,我已经做过了(将单个活动主题设置为android:theme=“@style/LaunchScreenTheme”
,并将整个应用程序主题设置为android:theme=“@style/AppTheme”
),但是它仍然为我的单个活动显示AppTheme
。有什么想法吗?将应用程序主题设置为android:theme=“@style/LaunchScreenTheme”
,然后为所需的活动创建另一个样式,它将正常工作。您的自定义样式应该是这样的-false-true
我已经做到了(将单个活动主题设置为android:theme=“@style/LaunchScreenTheme”
,并将整个应用程序主题设置为android:theme=“@style/AppTheme”
)但是它仍然显示我个人活动的AppTheme
。有什么想法吗?将应用程序主题设置为android:theme=“@style/LaunchScreenTheme”
,然后为所需的活动创建另一个样式,它将正常工作。您的自定义样式应该如下-false-true