Android action bar tab bar divider - android

I am having problem setting the drawable for the divider. My style.xml looks like this:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="HCLTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/HCLActionBarStyle</item>
<item name="actionBarStyle">#style/HCLActionBarStyle</item>
<item name="android:actionBarTabBarStyle">#style/HCLActionBarTabBarStyle</item>
<item name="android:actionBarTabStyle">#style/HCLActionBarTabStyle</item>
</style>
<style name="HCLActionBarStyle" parent="android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/hcl_actionbar_drawable</item>
<item name="background">#drawable/hcl_actionbar_drawable</item>
<item name="android:titleTextStyle">#style/HCLActionBarTitle</item>
</style>
<style name="HCLActionBarTabBarStyle" parent="#android:style/Widget.Holo.ActionBar.TabBar">
<item name="android:showDividers">middle</item>
<item name="android:divider">#drawable/divider</item>
<item name="android:dividerPadding">0dp</item>
</style>
<style name="HCLActionBarTabStyle" parent="#android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">#drawable/action_bar_tab_style</item>
</style>
<style name="HCLActionBarTitle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
</resources>
In the HCLActionBarTabBarStyle I'm setting the #drawable/divider as the tab divider. This drawable is a 9patch image, a vertical black line.
Before i set the divider drawable in the xml I'm getting the normal white divider like this:
After i set the drawable in the styles.xml i get this:
So as you can see the divider just gets wider, and its not the black vertical line from the 9patch image. I'm not even sure what the drawable for the divider has to be? A picture or layer list, or can it be a color? In fact i tried all of these 3 but with no success.

Use the property of "actionBarDivider" on the custom style.
Something like below
<style name="AppTheme" parent="AppBaseTheme">
<!-- You app specific customization -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionMenuTextColor">#color/menu_state_list</item>
<item name="android:actionBarTabStyle">#style/tabStyle</item>
<item name="android:actionBarTabTextStyle">#style/tabTextColor</item>
<!-- Set it like this -->
<item name="android:actionBarDivider">#drawable/verticle_marker_thin</item>
</style>

create tab divider picture
in styles add an item shown below
<item name="android:actionBarTabBarStyle">#style/customTabBar</item>
code for devider in action bar tab indicator
<style name="customTabBar" parent="#style/Widget.AppCompat.ActionBar.TabBar">
<item name="android:showDividers">middle</item>
<!-- give your divider here -->
<item name="android:divider">#drawable/tabindicator</item>
<item name="android:dividerPadding">0dp</item>
where #drawble/tabindicator is a picture in drawble

Related

How to theme Android Material Theme UI Elements with Appcelerator?

There is this useful information and everything works well:
http://docs.appcelerator.com/platform/latest/#!/guide/Android_Themes
The image is also very helpful:
The problem is that I want to have white or very light gray in the top bar. When I set this as "android:textColorPrimary", however, the text is white in the top bar, but in all alerts for instance as well making it invisible/very difficult to read.
How can I set the text color of the bar to white and theme the alert messages and other text in the default text color (dark gray)?
The themeAndroid.xml in app/platform/android/res/values looks like this
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="materialTheme" parent="#style/Theme.AppCompat.Light">
<item name="colorPrimary">#2e7d32</item>
<item name="colorPrimaryDark">#005005</item>
<item name="colorAccent">#80d8ff</item>
<item name="colorSwitchThumbNormal">#49a7cc</item>
<item name="android:colorButtonNormal">#49a7cc</item>
<item name="android:textColorPrimary">#DADADA</item>
<item name="android:spinnerItemStyle">#style/SpinnerItem</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerDropDownItem</item>
</style>
If you want to style the color of the actionbar font you need to extend your theme like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyThemeActionbar" parent="Theme.AppCompat">
<item name="colorPrimary">#FF0000</item>
<item name="colorPrimaryDark">#000000</item>
<item name="actionBarStyle">#style/CustomTheme.ActionBarStyle</item>
<item name="actionBarTheme">#style/Theme.ActionBarTheme</item>
<!-- tab -->
<item name="actionBarTabTextStyle">#style/TabStyle</item>
<item name="android:actionBarTabTextStyle">#style/TabStyle</item>
</style>
<style name="Theme.ActionBarTheme" parent="style/Widget.AppCompat.Light.ActionBar">
<!-- actionbar arrow -->
<item name="colorControlNormal">#ffffff</item>
</style>
<style name="CustomTheme.ActionBarStyle" parent="style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<!-- actionbar -->
<item name="elevation">0dp</item>
<item name="android:actionMenuTextColor">#FFFFFF</item>
<item name="android:titleTextStyle">#style/CustomTheme.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">#style/CustomTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="CustomTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<!-- actionbar font -->
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="TabStyle" parent="style/Widget.AppCompat.Light.ActionBar.TabText">
<!-- tab font -->
<item name="android:textColor">#ffffff</item>
</style>
</resources>
Then you can set the font color and the primary color to a different value and leave other thinks to the default values

Styling spinner Android

I find the spinner to be very frustrating to use programmatically and to style
I'd like to change the styling from the first picture (where the arrow is pointing down in the center) to the second picture (where the arrow is angled and it's located in the bottom right).
How do I do this?
// styling for spinner
<style name="spinner_style">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:spinnerMode">dialog</item>
<item name="android:layout_marginBottom">0.05dp</item>
<item name="android:background">?android:selectableItemBackground</item>
<item name="android:dropDownSelector">?android:selectableItemBackground</item>
<item name="android:divider">#null</item>
</style>
Use Widget.Holo.Spinner as your parent style for the spinner:
<style name="spinner_style" parent="#android:style/Widget.Holo.Spinner">
<!-- YOUR STYLE HERE -->
</style>

menu items in action bar showing up weird

I created a custom theme for the action bar that makes it white, and having a tad bit of trouble, and I have not been able to find the solution. First of all I want the 'options button' to be red, like the text below. but especially I want when clicked the whole row to be highlighted, not like it is shown in the picture:
Sso here is the code for the theme I'm using:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="android:background">#color/White</item>
<item name="android:textColorLink">#color/White</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/White</item>
<item name="android:textColor">#color/Red</item>
</style>
</resources>
I was hoping I could also get the red text to be aligned right, and have tried multiple alignment methods with no luck.thanks.
You need styles for android:actionMenuTextColor to change the "options" text color and android:textAppearanceLargePopupMenu to change the PopupMenu text color.
<style name="Your.Theme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionMenuTextColor">#android:color/holo_red_dark</item>
<item name="android:textAppearanceLargePopupMenu">#style/TextAppearance.Red.PopupMenu.Large</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Example</item>
</style>
<style name="TextAppearance.Red.PopupMenu.Large" parent="#android:style/TextAppearance.DeviceDefault.Widget.PopupMenu.Large">
<item name="android:textColor">#android:color/holo_red_dark</item>
</style>
<style name="PopupMenu.Example" parent="#android:style/Widget.ListPopupWindow">
<item name="android:popupBackground">#drawable/your_background</item>
<!-- Or use -->
<item name="android:popupBackground">#android:color/white</item>
</style>

Android: Background change in styles.xml

I'm trying to change the background color to black in styles.xml. The background changes fine but the actionbar got dirty. Some part of the actiobar background stays the same while the other portion turns black. I don't want the actionbar to change color. Please help
<style name="Theme.ApplicationTheme" parent="#style/Theme.Sherlock">
<item name="android:background">#000000</item> <!-- This line is changing the actionbar color -->
<item name="actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
</style>
<style name="Widget.MyApplicationTheme.ActionBar" parent="Widget.Sherlock.ActionBar">
<item name="android:background">#2d2d2d</item>
<item name="background">#2d2d2d</item>
</style>
Add following two additional items:
<item name="android:windowBackground">#000000</item>
<item name="android:colorBackground">#000000</item>
So that your style would look like:
<style name="Theme.ApplicationTheme" parent="#style/Theme.Sherlock">
<item name="android:background">#000000</item> <!-- This line is changing the actionbar color -->
<item name="android:windowBackground">#000000</item>
<item name="android:colorBackground">#000000</item>
<item name="actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.MyTheme.ActionBar</item>
</style>

Applying shadow and text color for Title and Menu Item in Sherlock Action bar

I am trying to achieve 2 things
White Text for Menu Items, Title text color works
Text Shadows for Title and Menu item
All this on XML.
What works, after experiments?
Custom Action bar layout works just fine with shadows.
Text color for all Tiles works but text shadow has no effect
Text color for Menu item has no effect anywhere. In the example code when I declare MenuTextStyle in the main Theme tag, I am able to change text size but not color.
<style name="Theme.SexyApp" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">#style/Widget.SexyApp.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.SexyApp.ActionBar</item>
<item name="android:actionBarItemBackground">#drawable/list_state</item>
<item name="actionBarItemBackground">#drawable/list_state</item>
<item name="android:actionMenuTextAppearance">#style/Theme.SexyApp.ActionBar.MenuTextStyle</item>
<item name="actionMenuTextAppearance">#style/Theme.SexyApp.ActionBar.MenuTextStyle</item>
</style>
<style name="Widget.SexyApp.ActionBar" parent="#style/Widget.Sherlock.Light.ActionBar">
<item name="android:displayOptions">showHome|useLogo|showTitle</item>
<item name="android:titleTextStyle">#style/Theme.SexyApp.ActionBar.TextAppearance</item>
<item name="titleTextStyle">#style/Theme.SexyApp.ActionBar.TextAppearance</item>
</style>
<style name="Theme.SexyApp.ActionBar.TextAppearance" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">20dp</item>
<item name="android:textStyle">bold</item>
<item name="android:shadowColor">#333333</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowDy">1</item>
</style>
<style name="Theme.SexyApp.ActionBar.MenuTextStyle" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Menu">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">13dp</item>
<item name="android:textStyle">bold</item>
<item name="android:shadowColor">#333333</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowDy">1</item>
</style>
To change the menu item text color, you need to add the actionMenuTextColor item to your theme style as in the code below:
<style name="ThemeName" parent="#style/Theme.Sherlock.Light">
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>
To update the menu item text appearance (color, size, style) you need to make changes at two different places. The following answer is for sherlock.actionbar
1: In your themes.xml file add following lines:
<style name="Theme.Mytheme" parent="#style/Theme.Sherlock">
<item name="android:actionMenuTextAppearance">#style/CustomMenuItem</item> // define custom style in the style.xml file.
<item name="actionMenuTextColor">#color/mycolor</item>
<item name="android:actionMenuTextColor">#color/mycolor</item>
2: In your styles.xml
<style name="CustomMenuItem" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Menu">
<item name="android:textStyle">normal</item>
<item name="android:textSize">15sp</item>
<item name="android:textAllCaps">false</item>
</style>

Categories

Resources