Мой Activity_main.xml по-прежнему использует тему по умолчанию, даже после того, как я указал другую тему - PullRequest
0 голосов
/ 15 декабря 2018

Мой 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">

  ...

activity_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

Есть идеи почему?

Ответы [ 2 ]

0 голосов
/ 15 декабря 2018

если вы хотите установить тему специально для действия, то вы установили ее в манифесте следующим образом -

<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">

...

0 голосов
/ 15 декабря 2018

В activity_main.xml, попробуйте style:"@style/LaunchScreenTheme" вместо android:theme="@style/LaunchScreenTheme"

...