我的styles.xml文件中有AppTheme样式。在清单文件中,我选择它就像应用程序主题。 我想登录活动的独特风格,我创建了登录样式,并在清单中设置它。但它不起作用,LoginActivity仍然需要AppTheme。
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:name=".application.TrainerApp"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".activities.login.LoginActivity"
android:theme="@style/LoginTheme"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
在style.xml中
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="LoginTheme" parent="@style/AppTheme">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">true</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item>
</style>
答案 0 :(得分:1)
试试这样: -
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="LoginTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#ff0</item>
<item name="colorPrimaryDark">#0ff</item>
<item name="colorAccent">#f0f</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">true</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item>
</style>
而不是: -
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="LoginTheme" parent="@style/AppTheme">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="lollipop">true</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item>
</style>
答案 1 :(得分:0)
从应用标记中删除android:theme="@style/AppTheme"
,并分别为每个活动应用主题。有关详细信息,请参阅我的链接:http://androidkeeda.com/android-working-on-material-theme