I am trying to change the background color of the Popup menu in the action bar.
Everything that I try its always the same black color, that is by default.
This is what I have in my styles.xml
<style name="AppTheme" parent="Theme.AppCompat">
<item name="colorPrimary">#color/app_navbar_background</item>
<item name="colorPrimaryDark">#color/app_navbar_background</item>
<item name="colorAccent">#color/CadetBlue</item>
<item name="android:textColorSecondary">#color/black</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="#android:style/Widget.PopupMenu">
<item name="android:popupBackground">#color/MediumPurple</item>
</style>
And I do have the theme set in the AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
Does anybody know what I could be doing wrong
Try using this:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="android:itemBackground">#color/app_navbar_background</item>
</style>
Related
I am trying to create a fullscreen activity in Android. I add the FullscreenTheme style as follows. But the action bar still shows.
style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
</resources>
AndroidManifest.xml
<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/FullscreenTheme">
The project minimum SDK is API 21 Android 5.0 Lollipop.
Change Theme to this .
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
I have a ProgressBar, Switch, and TextInput, and I need to be able to specify a different color for each one of them.
When I do this, it changes the color of all 3 items.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorAccent">#e8c4c7</item>
</style>
I'm looking for a command that only changes the color of the UI Element I want. something like:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="progressBar">#aaaaaa</item>
<item name="switch">#bbbbbb</item>
<item name="textInput">#cccccc</item>
</style>
Unfortunately, I am unable to change the style for each element directly (cause im using ReactNative). I need a solution that uses those global settings.
style.xml:
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar, also for button color-->
<item name="android:colorPrimary">#color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">#color/accent</item>
<!--progress bar theme-->
<item name="android:progressBarStyle">#style/myprogress</item>
<!--switch button theme-->
<item name="android:switchStyle">#style/myswith</item>
</style>
</resources>
<!--progress bar style,-->
<style name="myprogress" parent="Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:background">#color/white_color</item>
</style>
<style name="myswitch" parent="Widget.AppCompat.CompoundButton.Switch"></style>
Manifest.xml:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".activity.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Sample:
Some code like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:progressBarStyle">#style/progress</item>
<item name="android:switchStyle">#style/swith</item>
<item name="android:textAppearance">#style/text</item>
</style>
<style name="progress" parent="Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:background"></item>
</style>
<style name="swith" parent="Widget.AppCompat.CompoundButton.Switch"></style>
<style name="text" parent="TextAppearance.AppCompat"></style>
I try to change the default color of the popup menu by using styles:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:popupMenuStyle">#style/PopUp</item>
</style>
<style name="PopUp" parent="#android:style/Widget.PopupMenu">
<item name="android:popupBackground">#color/white</item>
</style>
I have hooked up this theme in app manifest.
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19"/>
<application
android:name=".MyApplication"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
However this does not change the default grey background of the popup. Any ideas whats wrong?
I changed
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:popupMenuStyle">#style/PopUp</item>
</style>
to
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:popupMenuStyle">#style/PopUp</item>
</style>
now it works. However it seems that using android:Theme.Holo.Light.DarkActionBar you cannot change the style of the popup through xml.
It's possible to change titelbar appearence? i would make it transparent and change default settings icon with a custom image. This is how my theme is write:
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowBackground">#drawable/my_bg</item>
</style>
<style name="AppTheme" parent="#android:style/Theme.DeviceDefault">
<item name="android:textColor">#colorhere</item>
<item name="android:windowTitleBackgroundStyle">#style/WindowTitleBackground</item>
</style>
<style name="WindowTitleBackground">
<item name="android:background">#colorhere</item>
</style>
and don't forget to check
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
Take a look at the Android Action Bar Style Generator, it is a very useful tool for styling your Action Bar.
I want to set my application to full screen view. I got the idea to set it in an individual activity using FullScreen and NoTitlebar, but i want to set it in my Manifest XML file for the whole application not for each activity... Is this possible?
Help me... Thanks.
To set your App or any individual activity display in Full Screen mode, insert the code
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
in AndroidManifest.xml, under application or activity tab.
Another way: add windowNoTitle and windowFullscreen attributes directly to the theme (you can find styles.xml file in res/values/ directory):
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
in the manifest file, in application specify your theme
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
If your Manifest.xml has the default android:theme="#style/AppTheme"
Go to res/values/styles.xml and change
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
And the ActionBar is disappeared!
In AndroidManifest.xml, set android:theme="#android:style/Theme.NoTitleBar.Fullscreen"in application tag.
Individual activities can override the default by setting their own theme attributes.
Try using these theme: Theme.AppCompat.Light.NoActionBar
Mi Style XML file looks like these and works just fine:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
This seems to be an old questions with some old answers. We found that the easiest way to do this in a new project is to edit the res/values/themes/themes.xml file.
Actionbar:
Change the parent attribute in the style element to "Theme.MaterialComponents.DayNight.NoActionBar" like this
<style name="Theme.WeatherDisplay" parent="Theme.MaterialComponents.DayNight.NoActionBar">
Status bar:
Add the following line under the style element
<item name="android:windowFullscreen">true</item>
Here is the resulting themes.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.NameOfApp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/purple_500</item>
<item name="colorPrimaryVariant">#color/purple_700</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/teal_200</item>
<item name="colorSecondaryVariant">#color/teal_700</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="android:windowFullscreen">true</item>
</style>