Cant style Android ActionMode - java

I am making a notes app.In that app i want an actionmode to trigger when long pressed on any item.It works but i cant change any style attributes of the actionmode.I have included my custom style in the styles.xml of my app, still doesn't work
styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/white</item>
<item name="android:textColor">#color/black</item>
<item name="colorPrimaryVariant">#color/blue_main</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/white</item>
<item name="colorSecondaryVariant">#color/white</item>
<item name="colorOnSecondary">#778899</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="m">#D3D3D3</item>
<item name="android:actionBarStyle" >#style/Theme.AppCompat.Light</item>
<item name="actionModeStyle">#style/Widget.ActionMode</item>
<item name="actionBarTheme">#style/Theme.AppCompat.Light</item>
</style>
<style name="Widget.ActionMode" parent="#style/Widget.AppCompat.Light.ActionMode.Inverse">
<item name="background">?attr/actionModeBackground</item>
<item name="android:actionBarDivider">#null</item>
<item name="actionModeCloseDrawable">#drawable/cancel</item>
<item name="android:actionModeBackground">#android:color/white</item>
</style>
<style name="CustomMaterialDialog" parent="#style/ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<!-- Background Color-->
<item name="android:background">#FFFFFF</item>
<!-- Text Color for title and message -->
<item name="colorOnSurface">#BF40BF</item>
<!-- Text Color for buttons -->
<item name="colorPrimary">#BF40BF</item>
<item name="shapeAppearanceOverlay">#style/ShapeAppearance.MaterialComponents.LargeComponent
</item>
</style>
</resources>
I specifically want to remove a green divider line that shows up at the bottom of the contextual menu i have attached the picture please see green divider line below the action mode menu

solved it. The problem was with the theme applied to the custom toolbar that i implemented. applied the lighttheme and everything works fine

Related

How to disable dark mode in android 9

i am trying to disable dark mode in my app and its working on android 10 or higher but its not working on android 9. Can anyone please help me out here. Thanks in advance.
In on create method i have done below,
in theme or theme(night), in both files i placed
<style name="Theme.VideoTradieProvider" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- <style name="Theme.VideoTradieProvider" parent="Theme.MaterialComponents.Light.NoActionBar">-->
<!-- Primary brand color. -->
<item name="android:windowActivityTransitions">true</item>
<!-- <item name="android:windowEnterTransition">#transition/explode_old</item>-->
<!-- <item name="android:windowExitTransition">#transition/explode_old</item>-->
<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">#color/white</item>
<item name="android:windowLightStatusBar">true</item>
<!-- Customize your theme here. -->
</style>
also write below line but not working with anroid 9
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
Change the parent attribute of your app style in themes.xml from
<style name="Theme.AppName" parent="Theme.MaterialComponents.DayNight.NoActionBar">
to
<style name="Theme.AppName" parent="Theme.MaterialComponents.Light.NoActionBar">
Is it Right As Josh and another way to see if You have the theme(night) then delete it

Android Navigation Fragment background is black without setting

First in my Android Stuidio, it look like this :
enter image description here
But in my Android Phone, it look like this:
enter image description here
When I turn to task List, it look like this:
enter image description here
Here are the themes.xml code:
themes.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.ShareChargingPile2.Fullscreen" parent="Theme.ShareChargingPile2">
<item name="android:actionBarStyle">
#style/Widget.Theme.ShareChargingPile2.ActionBar.Fullscreen
</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
</style>
<style name="ThemeOverlay.ShareChargingPile2.FullscreenContainer" parent="">
<item name="fullscreenBackgroundColor">#color/light_blue_600</item>
<item name="fullscreenTextColor">#color/light_blue_A200</item>
</style>
</resources>
Question: Why the background of my application is black? And how to fix this?
Solved
In the themes.xml
<style name="Theme.ShareChargingPile2.Fullscreen" parent="Theme.ShareChargingPile2">
<item name="android:actionBarStyle">
#style/Widget.Theme.ShareChargingPile2.ActionBar.Fullscreen
</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
</style>
the windowBackground is #null.
I change to #color/white. The problem solved
<style name="Theme.ShareChargingPile2.Fullscreen" parent="Theme.ShareChargingPile2">
<item name="android:actionBarStyle">
#style/Widget.Theme.ShareChargingPile2.ActionBar.Fullscreen
</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#color/white</item>
</style>
your phone dark mode is on or you can change in res->values->themes->themes.xml(night)change black to white or something else color.

Android use notch (status bar) area in fullscreen

I am currently making a gallery app and I want to use the full screen for displaying my images. For this I would have to use the Notch area on my Oneplus 6T as well, which I cannot get to work. Ever source I've looked at said to use windowLayoutInDisplayCutoutMode which doesn't seem to work for me and the Notch area is still blacked out and unused by the app. I have totally run out of ideas of how to fix this and cannot find any more results on the internet.
App Theme:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Raspjannis" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/pastelBlue</item>
<item name="colorPrimaryVariant">#color/iconBlue</item>
<item name="colorOnPrimary">#color/black</item>
<item name="android:textColor">#color/black</item>
<item name="android:textColorPrimary">#color/black</item>
<item name="android:textColorSecondary">#color/iconBlue</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/iconBlue</item>
<item name="colorSecondaryVariant">#color/pastelBlue</item>
<item name="colorOnSecondary">#color/white</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimary</item>
<!-- Customize your theme here. -->
<!-- Backgrounds Theme -->
<item name="backgroundColor">#color/pastelBlue</item>
<item name="cardBackgroundColor">#color/white</item>
<item name="cardForegroundColor">#color/white</item>
<item name="editTextBackground">#color/bright</item>
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="p">
shortEdges <!-- default, shortEdges, or never -->
</item>
</style>
<style name="Theme.Raspjannis.NoActionBar.splashScreenTheme" parent="Theme.Raspjannis.NoActionBar">
<item name="android:windowBackground">#drawable/splash_screen</item>
</style>
<style name="ActionBarTheme">
</style>
<style name="Theme.Raspjannis.NoActionBar" parent="Theme.Raspjannis">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.Raspjannis.NoStatusBar">
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="p">
shortEdges <!-- default, shortEdges, or never -->
</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="Theme.Raspjannis.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="Theme.Raspjannis.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<!-- This style is where you define the tint color of your overflow menu button -->
<style name="actionOverflowButtonStyle" parent="#style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:tint">#color/dark</item>
</style>
<style name="menuItem" parent="Widget.AppCompat.TextView.SpinnerItem">
<item name="android:textColor">#color/black</item>
<item name="android:textColorPrimary">#color/black</item>
</style>
<style name="icons" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:itemBackground">#color/white</item>
<item name="android:textColor">#color/dark</item>
<item name="android:tint">#color/dark</item>
</style>
And here is the code that sets the theme and fullscreen:
public static void hideSystemUI(Activity activity) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
activity.setTheme(R.style.Theme_Raspjannis_NoStatusBar);
}
public static void showSystemUI(Activity activity) {
activity.setTheme(R.style.Theme_Raspjannis);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

Change action bar Title font & color

I wanna change my action bar title font & color. so now im doing like this code. also i'm using typekit library too. i dont know why not change now
plz have some advice for me
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorCyanAzure</item>
<item name="colorPrimaryDark">#color/colorWhite</item>
<item name="colorAccent">#color/colorMelon</item>
<item name="android:actionBarStyle">#style/AppTheme.MyActionBar</item>
</style>
<style name="AppTheme.MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.MyActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/colorWhite</item>
<item name="android:textStyle">normal</item>
</style>
Change you Theme.AppCompat.Light to Theme.AppCompat.Light.DarkActionBar and tried code as below
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<style name="AppTheme.MyActionBar"parent="#style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">#style/MyTitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/colorWhite</item>
<item name="android:textStyle">normal</item>
</style>
You could use a toolbar. When you have a reference to the toolbar and you want to style the title, you could do something like this
TextView textView = (TextView)toolbar.getChildAt(0);
//set the font and font color.
If you have more children in the toolbar, you may want to loop through and find the child you want to style

How to hide the action-bar in style xml themes while loading

I have a custom theme that I displayed for my application. However, in my main activity class I set a custom font for the action bar font.
// Make sure you find out why it appears after a whole 1 second after the app appears
SpannableString s = new SpannableString("GetDisciplined");
s.setSpan(new TypefaceSpan(this, "roboto-light.ttf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Update the action bar title with the TypefaceSpan instance
ActionBar actionBar = getActionBar();
actionBar.setTitle(s);
// set the action bar in this activity as the home
actionBar.setHomeButtonEnabled(true);
Upon launching the app, I want to immediately show the custom font.
I did some research and most solutions didn't work, but I am trying to now use launch a "splash screen" application theme without an action bar and then set the custom_theme with an action in my main activity class.
Kind of like this.
https://stackoverflow.com/a/12724687/3120659
But I am unsure how to do that modify my current style theme to do that.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Light_appalled" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_light_appalled</item>
<item name="popupMenuStyle">#style/PopupMenu.Light_appalled</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Light_appalled</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Light_appalled</item>
<item name="actionDropDownStyle">#style/DropDownNav.Light_appalled</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Light_appalled</item>
<item name="actionModeBackground">#drawable/cab_background_top_light_appalled</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_light_appalled</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Light_appalled</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Light_appalled.Widget</item>
</style>
<style name="ActionBar.Solid.Light_appalled" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_light_appalled</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_light_appalled</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_light_appalled</item>
<item name="progressBarStyle">#style/ProgressBar.Light_appalled</item>
</style>
<style name="ActionBar.Transparent.Light_appalled" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/ab_transparent_light_appalled</item>
<item name="progressBarStyle">#style/ProgressBar.Light_appalled</item>
</style>
<style name="PopupMenu.Light_appalled" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_light_appalled</item>
</style>
<style name="DropDownListView.Light_appalled" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_light_appalled</item>
</style>
<style name="ActionBarTabStyle.Light_appalled" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_light_appalled</item>
</style>
<style name="DropDownNav.Light_appalled" parent="#style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_light_appalled</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_light_appalled</item>
<item name="android:dropDownSelector">#drawable/selectable_background_light_appalled</item>
</style>
<style name="ProgressBar.Light_appalled" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_light_appalled</item>
</style>
<style name="ActionButton.CloseMode.Light_appalled" parent="#style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_light_appalled</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Light_appalled.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Light_appalled</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Light_appalled</item>
</style>
</resources>
Unfortunately
<item name="android:windowNoTitle">true</item>
did not work, so I am trying to figure out how to do it.

Categories

Resources