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>
Related
I want to define a default style for my buttons so that I don't have to type style="#style/mainButtonStyle" inside of each button manually. I have already defined the style.
<style name="mainButtonStyle" parent="android:Widget.Material.Button">
<item name="android:background">#drawable/button_default_background</item>
<item name="android:textAllCaps">true</item>
<item name="android:textStyle">bold</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
And already added an android:buttonStyle attribute in the app's theme.
themes.xml
<!-- Base application theme. -->
<style name="Theme.PlanShopping" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#AA0000</item>
<item name="colorPrimaryVariant">#color/purple_700</item>
<item name="colorOnPrimary">#color/white</item>
<item name="colorSurface">#color/black</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:buttonStyle">#style/mainButtonStyle</item>
</style>
The Android Manifest has android:theme attribute set up by default.
<application
android:name=".PlannerApplication"
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.PlanShopping"
tools:targetApi="31">
...
</application>
So why is it not changing the default button style? The style works fine if I type it manually inside of a button. But it's not the result I wanted. How can I set it by default? I've tried to inherit from different types of buttons: android:Widget.Button, android:Widget.Holo.Button. Also, different <Button> types did not help. For now, I'm using a default <Button> component (not material or holo).
If the button is a MaterialButton you will need to specify:
<item name="materialButtonStyle">#style/mainButtonStyle</item>
I'm struggling to override the default themes app bar color properly.
When I use the android:actionBarStyle it changes the color but then the title text is missing.
<resources>
<style name="ToolbarThemeStyle" parent="android:Theme.Material.Light">
<item name="android:actionBarStyle">#style/ActionBarTitle.Background</item>
</style>
<style name="ActionBarTitle.Background" parent="">
<item name="android:background">#8DC44E</item>
<item name="android:titleTextStyle">#style/ActionBarTitle.Text</item>
</style>
<style name="ActionBarTitle.Text" parent="">
<item name="android:textColor">#FFFFFF</item>
</style>
</resources>
I've tried Replacing the Action Bar but I'm wondering if there's not a shorter and easier way.
Manifest:
<application android:label="Home Automation" android:icon="#mipmap/ic_launcher" android:theme="#android:style/Theme.Material.Light"
</application>
Activity:
[Activity(Label = "Label", MainLauncher = false, Theme = "#style/ToolbarThemeStyle", NoHistory =true)]
Thanks all for your replies. I thought I'd answer this myself whereas I've spent hours trying to figure this out.
The obvious solution was in this page under Using Custom Themes but I was getting the error "No resource found that matches the given name (android:color Primary)". Changing android:minSDKVersion=23 also did not work.
I went to Application Properties and set the "Compile using Android version" to the current targeting framework (i.e. API 23) instead of the maximum which was not installed yet set to API 25.
make sure are you setting theme to activity in menifest or xml. Here I am sharing my theme code you can refer.
<style name="MaterialAppTheme" parent="Theme.AppCompat.Light">
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#color/white</item>
<item name="android:textColorSecondary">#color/red</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
This code should be in you 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="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
And make sure you should have declared it in manifest.xml
<application
android:name=".app.AppController"
android:allowBackup="true"
android:icon="#drawable/images"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
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>
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.
How do i change the Overflow Menu icon on the far right of the action bar as seen in the image below? My Holo theme specifies this 3 row black stack icon by default and i want something else. i can't seem to find a solution for this. I have looked at the documentation on http://developer.android.com/guide/topics/ui/menus.html but it doesn't seem to lend much help.
Thanks!
You can try something like this:
<style name="MyTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionOverflowButtonStyle">#style/MyActionButtonOverflow</item>
</style>
<style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/my_action_bTutton_overflow</item>
</style>
and in AndroidManifest.xml
<application
android:theme="#style/MyTheme" >
Define a custom style: for example, let's call it customoverflow.
In this style you set android:src to the picture you would like to use.
Now create a style with parent Theme.holo.
In this style you need to define:
<item name="android:actionOverflowButtonStyle">#style/customoverflow</item>
I just tested this and it works.
If you are using AppCompat you can achieve by following code.
res/values/themes.xml
<style name="MyTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionOverflowButtonStyle">#style/ActionButtonOverflow</item>
<!-- Support library compatibility -->
<item name="actionOverflowButtonStyle">#style/ActionButtonOverflow</item>
</style>
<style name="ActionButtonOverflow" parent="#style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:src">#drawable/ic_launcher</item>
</style>
and in androidmanifest.xml
<application
android:theme="#style/MyTheme" >
I noticed that it becomes white if the theme of the app is Holo, but it is blackish when the theme is Holo.Light
However, changing the style of the action bar to inherit from Holo and the rest of the app from Holo.Light does not solve the problem, but it should point in the direction of which style you should be modifying.
What I have tried is:
<style name="AppThemeLight" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="android:windowContentOverlay">#drawable/actionbar_shadow</item>
</style>
<style name="ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/header_brown</item>
<item name="android:titleTextStyle">#style/ActionBarTitle</item>
<item name="android:icon">#drawable/header</item>
</style>
I have the same problem and I think this is close to a solution
Duplicate question,
Changing overflow icon in the action bar
This is my answer as below,
Change your custom overflow icon of Actionbar in styles.xml
<resources>
<!-- Base application theme. -->
<style name=“MyTheme" parent="#android:style/Theme.Holo">
<!-- Pointer to Overflow style DONT forget! -->
<item name="android:actionOverflowButtonStyle">#style/MyOverFlow</item>
</style>
<!-- Styles -->
<style name="MyOverFlow" parent="#android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/ic_your_action_overflow</item>
</style>
</resources>
Put custom theme "MyTheme" in application tag of AndroidManifest.xml
<application
android:name="com.example.android.MainApp"
android:theme="#style/AppTheme">
</application>
Have fun.#.#
Shalafi's solution works with a few changes! You will need to specifiy theme.Holo as the parent for the theme but it has the downside of changing the default text color(at least in my styles).
The amended code should be:
<style name="AppThemeLight" parent="android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/ActionBar</item>
<item name="android:windowContentOverlay">#drawable/actionbar_shadow</item>
</style>
<style name="ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/header_brown</item>
<item name="android:titleTextStyle">#style/ActionBarTitle</item>
<item name="android:icon">#drawable/header</item>
</style>
Basically Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backward-compatibility can go values/styles.xml
Shalafi's solution works with a few additions:So
add this code to both res/values-vXX/styles.xml and res/values/styles.xml and this will work like Magic!
<style name="AppTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionOverflowButtonStyle">#style/MyActionButtonOverflow</item>
</style>
<style name="MyActionButtonOverflow"parent="android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/your_overflow_icon</item>
</style>
also add it in AndroidManifest.xml
<application
android:theme="#style/AppTheme" >
<style name="ToolBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:tint">#color/colorAccent</item>
create the above theme.set tint with your color and add this theme to the toolbar.
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ToolBarTheme"/>