I am using a theme in styles.xml as below:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/md_blue_700</item>
<item name="android:colorAccent">#color/md_blue_900</item>
<item name="android:colorPrimaryDark">#color/md_blue_900</item>
<item name="android:windowBackground">#color/md_white_1000</item>
<item name="android:colorControlNormal">#color/md_blue_700</item>
<item name="android:colorControlActivated">#color/md_blue_700</item>
<item name="android:colorControlHighlight">#color/md_blue_700</item>
<item name="android:textColorPrimary">#color/md_white_1000</item>
</style>
which I am declaring as android:theme in AndroidManifest.xml:
<activity
android:name=".LoginActivity"
android:theme="#style/AppTheme"
android:label="#string/activity_login_actionbar" />
The problem is highlighted in red in the image below.
Since I am setting
<item name="android:textColorPrimary">#color/md_white_1000</item>
to white the text in the progress bar also appears white and is invisible. If I change it to gray, the text in the action bar also changes to gray which I do not want.
I have tried things such as creating a seperate theme for the progress dialog but when I do that I lose the rounded corners of the dialog box and such.
This is my java code for creating the spinner:
progressDialog = new ProgressDialog(this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setTitle("Attempting Sign In");
progressDialog.setMessage("Please wait...");
progressDialog.setCancelable(false);
How should I go about solving this problem?
All answers appreciated!
You can use Theme.AppCompat.Light.DarkActionBar and remove <item name="android:textColorPrimary">#color/md_white_1000</item> in your theme style, then the title will become white. You can check the comparison between Light and Dark themes here
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/md_blue_700</item>
<item name="android:colorAccent">#color/md_blue_900</item>
<item name="android:colorPrimaryDark">#color/md_blue_900</item>
<item name="android:windowBackground">#color/md_white_1000</item>
<item name="android:colorControlNormal">#color/md_blue_700</item>
<item name="android:colorControlActivated">#color/md_blue_700</item>
<item name="android:colorControlHighlight">#color/md_blue_700</item>
</style>
Related
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
By Default, the View Pager(Swipe Tabs) Tab title color is White but i want to change into orange. Can any one help me please or share if you have any tutorial.
Thanks...
Use this style in your styles.xml and assign the style to your tab layout.
<style name="MyMaterialTheme.TabLayout" parent="Widget.Design.TabLayout">
<item name="tabIndicatorColor">#android:color/white</item>
<item name="tabIndicatorHeight">3dp</item>
<item name="tabTextAppearance">#style/MyMaterialTheme.TabLayout.TextAppearance</item>
<item name="tabSelectedTextColor">#android:color/white</item>
<item name="android:background">#color/colorPrimary</item>
</style>
<style name="MyMaterialTheme.TabLayout.TextAppearance" parent="TextAppearance.Design.Tab">
<item name="android:textSize">14sp</item>
<item name="android:textColor">#color/tab_text_inactive</item>
<item name="textAllCaps">true</item>
</style>
Check implementation from here.
I want show divider for only beginning of menu item in particular fragment. I tried some code in my theme but its not shown.
My code here:
<style name="MyActionBar" parent="Widget.AppCompat.ActionBar.Solid">
<item name="background">#color/myPrimaryColor</item>
<item name="logo">#drawable/s</item>
<item name="displayOptions">useLogo|showHome</item>
<item name="android:actionBarDivider">#color/myDrawerBackground</item>
<item name="android:showDividers">beginning</item>
<item name="titleTextStyle">#style/MyTitleTextStyle</item>
</style>
Please anyone help to fix.
Thanks in advance.
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.
How can one change the color of the overflow icon in the action bar?
(The most right icon)
You can use 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>
in your AndroidManifest.xml
<application
android:theme="#style/MyTheme" >
If you want to change actionBar color
#style/MyActionBar
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/app_theme_color</item>
<!-- Support library compatibility -->
<item name="background">#color/app_theme_color</item>
<item name="android:alwaysDrawnWithCache">true</item>
<item name="android:displayOptions">showTitle|showHome|homeAsUp</item>
<item name="android:icon">#android:color/transparent</item>
</style>
Then in your AndroidManifest.xml you need to refer this one inside your application tag.
android:theme="#style/CustomActionBarTheme"
If you just want to change the color you can simply tint it:
<style name="DotsDarkTheme" parent="#style/Widget.AppCompat.ActionButton.Overflow" >
<item name="android:tint">#color/yourColor</item>
</style>
and then use it in your style:
<item name="actionOverflowButtonStyle">#style/DotsDarkTheme</item>
if you are using action bar use :
toolbar.getOverflowIcon().setColorFilter(Color.WHITE , PorterDuff.Mode.SRC_ATOP);
It's also worth adding that if you simply want to change the overflow button to a light or dark colour to go with your action bar colour this can be done without specifying a custom icon.
For a dark button colour set your theme as:
<style name="MyTheme" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyTheme.ActionBar</item>
</style>
For a light button colour add DarkActionBar:
<style name="MyTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyTheme.ActionBar</item>
</style>
If, like me, you want a light button colour but you want the overflow menu to be light you can do the following:
<style name="MyTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyTheme.ActionBar</item>
<item name="android:actionBarWidgetTheme">#style/MyTheme.ActionBarWidget</item>
</style>
<!-- This helps the PopupMenu stick with Light theme while the ActionBar is in Dark theme -->
<style name="MyTheme.ActionBarWidget"
parent="android:Theme.Holo.Light">
<item name="android:popupMenuStyle">#android:style/Widget.Holo.Light.PopupMenu</item>
<item name="android:dropDownListViewStyle">#android:style/Widget.Holo.Light.ListView.DropDown</item>
</style>
You can use your custom style inside for menu item, like this
<item name="android:itemTextAppearance">#style/myCustomMenuTextApearance</item>
Define the style like this:
<style name="myCustomMenuTextApearance" parent="#android:style/TextAppearance.Widget.IconMenu.Item">
<item name="android:textColor">#android:color/primary_text_dark</item>
</style>
Also see Change the background color of the options menu and
Android: customize application's menu (e.g background color)
Create below style in styles.xml with parent as ActionButton Overflow widget
and then use that theme in the style that you are using for that activity where toolbar is shown.
Step-1) Creating style for the actionButtonOverflow
<style name="DotsDarkTheme" parent="#style/Widget.AppCompat.ActionButton.Overflow" >
<item name="android:tint">your color</item>
</style>
Step-2) Using this style in the activity that is using actionBar
<style name="CustomMainActivityTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="actionOverflowButtonStyle">#style/DotsDarkTheme</item>
</style>