Issue
I'm trying to customize my Android theme, but nothing seems to work.
Activity:
public class MainActivity extends AppCompatActivity {
...
}
themes.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Delete" parent="Theme.MaterialComponents.Light">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryVariant">@color/primary</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/primary</item>
<item name="colorSecondaryVariant">@color/primary</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="materialButtonStyle">@style/Widget.App.Button</item>
</style>
<style name="Widget.App.Button" parent="Widget.MaterialComponents.Button">
<item name="materialThemeOverlay">@style/ThemeOverlay.Button</item>
<item name="colorPrimary">@color/primary</item>
</style>
<style name="ThemeOverlay.Button" parent="" >
<!-- For filled buttons, your theme's colorPrimary provides the default background color of the component-->
<item name="colorPrimary">@color/primary</item>
</style>
</resources>
In layout I'm using Material Design Components for example
<com.google.android.material.button.MaterialButton
android:id="@+id/button_home_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/home_all"
app:layout_constraintStart_toStartOf="parent"/>
but the default purple_200
background color is applied to the button. Can you help me a bit? I read that there I should use Activity
instead of AppCompatActivity
but I can't change it as my activity is a bottom navigation activity I can't find support for onSupportNavigateUp
or other realated stuff
EDIT
AndroidManifest.xml<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="licenta.allbank">
<application
android:requestLegacyExternalStorage="true"
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/Theme.AllBank"
android:usesCleartextTraffic="true">
<activity
android:name=".activity.MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="callback"
android:scheme="https" />
</intent-filter>
</activity>
</application>
</manifest>
Solution
Figured it out. If you're testing on your phisical device and it is set on dark mode, you should make the changes in your values-night/themes.xml
file, otherwise, working on your values/themes.xml
should be enough
Answered By - Andrei Manolache
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.