How to show ActionBar MenuItem Divider in AppCompat.ActionBar.Solid Theme - java

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.

Related

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

Android Action Bar Text Custom Color

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>

How to Change swipe Tab Title color in java Android

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.

Removing default actionbar tab padding

My problem is that I can't seem to override androids default tab padding and it's making my tabs horizontally scrollable (which I don't want). I've searched around stack overflow and other sites online but i can't find a solution for my problem. I am using appcompat-v7 and I'm targeting api 21 with my minimum sdk set to api 14.
Here is my themes.xml
<style name="TSTheme"
parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle</item>
<item name="colorPrimary">#color/primary_blue_500</item>
<item name="colorPrimaryDark">#color/dark_blue</item>
<item name="colorAccent">#color/primary_blue_500</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/primary_blue_500</item>
</style>
<style name="ActionBarTabStyle"
parent="#style/Widget.AppCompat.Light.ActionBar.TabView.Inverse">
<item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:paddingTop">0dp</item>
</style>
I have tried adding android: prefix but it still doesn't do anything. I have also defined my custom theme in my manifest
Any and all help is much appreciated
For this you will have to create your own style and then you can set that style to actionbar manually. This is the only way to make it done.
<item name="toolbarStyle">#style/Widget.Toolbar</item>
<style name="Widget.Toolbar" parent="#style/Widget.AppCompat.Toolbar">
<item name="contentInsetStart">0dp</item>
</style>

Change the action bar settings icon color

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>

Categories

Resources