Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 即使我指定了另一个主题,我的activity_main.xml仍然使用默认主题_Android_Android Theme - Fatal编程技术网

Android 即使我指定了另一个主题,我的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

即使我指定了另一个主题,我的activity_main.xml仍然使用默认主题。请在下面找到我的代码:

风格

<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 settings
style=“@style/LaunchScreenTheme”
。它不起作用-仍然使用默认的
AppTheme
尝试使用style
style=“@style/AppTheme”
而不是theme。如果要使用主题,请在清单文件中将其指定为
inline?我仍然希望
AppTheme
成为默认值,但我希望activity_main.xml在清单中使用
LaunchScreenTheme
,我告诉你要将主题设置为完美的活动,而不是应用程序标记。如果你想在xml中使用,那么在xml文件中指定它为styleJust tested settings
style=“@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