Can't fix styles for toolbar in the action mode - android

I can't get how to fix styles for my Toolbar in the action mode.
<!-- DialogWhenLarge uses to show Activity as Dialog on the tablet -->
<style name="Theme.Paper.DialogWhenLarge" parent="Theme.AppCompat.Light.DialogWhenLarge">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionBarTheme">#style/Theme.Paper.Toolbar</item>
<item name="actionBarPopupTheme">#style/Theme.Paper.Toolbar.PopupOverlay</item>
<!-- Below attributes available on the v11+ only -->
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
<style name="Theme.Paper.Toolbar" parent="Theme.Paper">
<item name="android:background">#color/primary</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="android:textColorSecondary">#color/white</item>
<item name="colorControlNormal">#color/white</item>
<item name="colorControlHighlight">#color/accent</item>
<item name="colorControlActivated">#color/white</item>
<item name="actionMenuTextColor">#color/white</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
</style>
<style name="Theme.Paper.Toolbar.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="android:textColorPrimary">#color/black_87</item>
<item name="android:textColorSecondary">#color/black_54</item>
<item name="android:colorBackground">#color/white</item>
<item name="colorControlHighlight">#color/black_30</item>
<item name="colorControlActivated">#color/white</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
</style>
What is my problem in? And what do I want to get? I posted it below.
Correct toolbar style is as I need
But in action mode it looks so (white actions and a menu with primary color background and white text)
P.S. I tried to fix it but each time I get wrong styles.

I don't sure... but maybe a someone will have the same problem. So below the solution that works for me:
<resources>
<!--
*
* App themes
*
-->
<!-- DialogWhenLarge uses to show Activity as Dialog on the tablet -->
<style name="Theme.Paper.DialogWhenLarge" parent="Theme.AppCompat.Light.DialogWhenLarge">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="actionBarPopupTheme">#style/Theme.Paper.Toolbar.PopupOverlay</item>
<item name="actionModeStyle">#style/Theme.Paper.ActionMode</item>
<!-- Below attributes available on the v11+ only -->
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
<!--
*
* ActionBar, AppBarLayout and Toolbar styles
*
-->
<!-- Action mode -->
<style name="Theme.Paper.ActionMode" parent="Widget.AppCompat.ActionMode">
<item name="background">#color/primary</item>
</style>
<!-- Toolbar -->
<style name="Theme.Paper.Toolbar" parent="Theme.Paper">
<item name="android:background">#color/primary</item>
<item name="android:textColorPrimary">#color/white</item>
<item name="android:textColorSecondary">#color/white</item>
<item name="colorControlNormal">#color/white</item>
<item name="colorControlHighlight">#color/accent</item>
<item name="colorControlActivated">#color/white</item>
<item name="actionMenuTextColor">#color/white</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
</style>
<!-- Toolbar popup overlay -->
<style name="Theme.Paper.Toolbar.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="android:textColorPrimary">#color/black_87</item>
<item name="android:textColorSecondary">#color/black_54</item>
<item name="android:colorBackground">#color/white</item>
<item name="colorControlHighlight">#color/black_30</item>
<item name="colorControlActivated">#color/white</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat.Light</item>
</style>
</resources>

Related

Overriding Style XML for Component

im using Material IO and i want to Change the Text-Color of my Menu.
<resources>
...
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
...
<item name="android:textColorPrimary">#color/colorText</item>
</style>
...
<resources>
Does exactly that. But it changes every Text Color. But i just want to Change the Color of my Menu-Text.
So i tried to change only that:
<style name="ActionBarTheme" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:textColor">#color/colorMenuText</item> //android.view
<item name="android:textColorPrimary">#color/colorMenuText</item>
<item name="android:actionMenuTextAppearance">#color/colorWhite</item>
<item name="android:background">#color/colorAccent</item>
<item name="popupTheme">#style/ActionBarPopupTheme</item>
<!-- backward compatibility -->
<item name="background">#color/colorAccent</item>
</style>
by writing some Thing like This.
I can change the Menu-Background this way, but i cant change the Menu-Text-Color this way. I tried everything i found on Stackoverflow but i couldnt fix this issue.
Whole Styles.xml
<resources>
<style name="ActionBarTheme" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:textColor">#color/colorMenuText</item> //android.view
<item name="android:textColorPrimary">#color/colorMenuText</item>
<item name="android:actionMenuTextAppearance">#color/colorWhite</item>
<item name="android:background">#color/colorAccent</item>
<item name="popupTheme">#style/ActionBarPopupTheme</item>
<!-- backward compatibility -->
<item name="background">#color/colorAccent</item>
</style>
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:colorAccent">#0000FF</item>
</style>
<style name="ActionBarPopupTheme">
<item name="android:textColor">#color/colorMenuText</item>
<item name="android:background">#color/colorMenuBackground</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
<!-- MENU -->
<item name="android:actionBarStyle">#style/ActionBarTheme</item>
<item name="actionBarStyle">#style/ActionBarTheme</item>
<!-- DIALOG -->
<item name="md_color_title">#color/colorPrimary</item>
<item name="md_color_content">#color/colorPrimaryDark</item>
<item name="md_color_button_text">#color/colorAccent</item>
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorTest2</item>
<item name="colorPrimaryDark">#color/colorTest3</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:actionMenuTextColor">#color/colorMenuText</item>
<item name="android:textColor">#color/colorWhite</item>
<item name="color">#color/colorTest4</item>
<item name="colorSecondary">#FF0000</item>
<item name="android:colorBackground">#color/colorBackground</item>
<item name="colorError">#color/colorError</item>
<item name="colorPrimaryVariant">#color/colorAccent</item>
<item name="colorSecondaryVariant">#color/colorTest</item>
<item name="colorSurface">#313131</item>
<item name="colorOnPrimary">#00BCD4</item>
<item name="colorOnSecondary">#00BCD4</item>
<item name="colorOnBackground">#673AB7</item>
<item name="colorOnError">#2196F3</item>
<item name="colorOnSurface">#color/colorOnAccent</item> <!-- placeholder farbe -->
<item name="scrimBackground">#E607FF</item>
<item name="android:editTextColor">#color/colorText</item>
<item name="android:textColorPrimary">#color/colorText</item>
<item name="android:textColorSecondary">#color/colorText</item>
<item name="android:textColorTertiary">#color/colorText</item>
<item name="android:textColorPrimaryInverse">#color/colorText</item>
<item name="android:textColorSecondaryInverse">#color/colorText</item>
<item name="android:textColorTertiaryInverse">#color/colorText</item>
</style>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/colorMenuText</item>
</style>
<style name="Theme.MyApp" parent="Theme.AppCompat">
<!-- DIALOG -->
<item name="md_color_title">#color/colorPrimary</item>
<item name="md_color_content">#color/colorPrimaryDark</item>
<item name="md_color_button_text">#color/colorAccent</item>
<!-- Original AppCompat attributes. -->
<item name="colorPrimary">#color/colorTest4</item>
<item name="colorSecondary">#color/colorTest5</item>
<item name="android:colorBackground">#color/colorBackground</item>
<item name="colorError">#color/colorError</item>
<!-- New MaterialComponents attributes. -->
<item name="colorPrimaryVariant">#color/colorAccent</item>
<item name="colorSecondaryVariant">#color/colorTest</item>
<item name="colorSurface">#313131</item>
<item name="colorOnPrimary">#9C27B0</item>
<item name="colorOnSecondary">#00BCD4</item>
<item name="colorOnBackground">#673AB7</item>
<item name="colorOnError">#2196F3</item>
<item name="colorOnSurface">#E91E63</item>
<item name="scrimBackground">#FFC107</item>
<item name="textAppearanceHeadline1">#style/TextAppearance.MaterialComponents.Headline1</item>
<item name="textAppearanceHeadline2">#style/TextAppearance.MaterialComponents.Headline2</item>
<item name="textAppearanceHeadline3">#style/TextAppearance.MaterialComponents.Headline3</item>
<item name="textAppearanceHeadline4">#style/TextAppearance.MaterialComponents.Headline4</item>
<item name="textAppearanceHeadline5">#style/TextAppearance.MaterialComponents.Headline5</item>
<item name="textAppearanceHeadline6">#style/TextAppearance.MaterialComponents.Headline6</item>
<item name="textAppearanceSubtitle1">#style/TextAppearance.MaterialComponents.Subtitle1</item>
<item name="textAppearanceSubtitle2">#style/TextAppearance.MaterialComponents.Subtitle2</item>
<item name="textAppearanceBody1">#style/TextAppearance.MaterialComponents.Body1</item>
<item name="textAppearanceBody2">#style/TextAppearance.MaterialComponents.Body2</item>
<item name="textAppearanceCaption">#style/TextAppearance.MaterialComponents.Caption</item>
<item name="textAppearanceButton">#style/TextAppearance.MaterialComponents.Button</item>
<item name="textAppearanceOverline">#style/TextAppearance.MaterialComponents.Overline</item>
</style>
</resources>
I tried this minimum sample of your code and it gives me the desired behavior
I think there is a conflict with your styles
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="actionBarTheme">#style/ActionBarTheme</item>
</style>
<style name="ActionBarTheme" parent="#style/ThemeOverlay.MaterialComponents.ActionBar">
<item name="android:textColorPrimary">#ffffff</item>//for title text color
<item name="colorPrimary">#D81B60</item>// for toolbar background
<item name="popupTheme">#style/ActionBarPopupTheme</item>
</style>
<style name="ActionBarPopupTheme">
<item name="android:textColor">#304FFE</item> // for option menu text color
</style>

Android action bar overflow menu remove shadow

I'd like to remove shadow around my action bar overflow menu, but i haven't found any attributes allowing that. I'm extending Theme.AppCompat.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="actionOverflowButtonStyle">#style/OverflowButton</item>
<item name="actionOverflowMenuStyle">#style/OverflowMenu</item>
<item name="actionBarStyle">#style/MyActionBarLogo</item>
<item name="android:dropDownListViewStyle">#style/PopupMenuListView</item>
<item name="dropDownListViewStyle">#style/PopupMenuListView</item>
<item name="android:textColor">#color/black</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
</style>
<style name="MyActionBarLogo" parent="Widget.AppCompat.ActionBar">
<item name="background">#color/white</item>
<item name="displayOptions">useLogo|showHome</item>
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="OverflowButton" parent="#style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:src">#mipmap/menu_logo</item>
</style>
<style name="OverflowMenu" parent="#style/Widget.AppCompat.PopupMenu.Overflow">
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">52dp</item>
<item name="android:dropDownHorizontalOffset">10dp</item>
</style>
<style name="PopupMenuListView" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:divider">#drawable/menu_divider</item>
<item name="android:dividerHeight">1dp</item>
<item name="android:textColor">#color/black</item>
<item name="android:background">#color/white</item>
</style>
<style name="PopupMenu" parent="#style/Widget.AppCompat.ListPopupWindow">
<item name="android:popupBackground">#color/white</item>
</style>
http://imgur.com/5mbceT9
You can try solution this
getSupportActionBar().setElevation(0);
UPDATE
<style name="MyActionBarLogo" parent="Widget.AppCompat.ActionBar">
<item name="background">#color/white</item>
<item name="displayOptions">useLogo|showHome</item>
<item name="elevation">0dp</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:actionDropDownStyle">#style/DropDownMenuStyle</item>
</style>
<style name="DropDownMenuStyle" parent="Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#android:color/transparent</item>
</style>
You need to apply the zero elevation style to the correct element, in this case actionOverflowMenuStyle.
(This is using appcompat)
<style name="Theme.myapp" parent="Theme.AppCompat.Light">
<item name="actionOverflowMenuStyle">#style/Theme.myapp.Widget.PopupMenu.Overflow</item>
</style>
Then
<style name="Theme.myapp.Widget.PopupMenu.Overflow" parent="Widget.AppCompat.PopupMenu.Overflow">
<item name="elevation">0dp</item>
<item name="android:popupElevation">0dp</item>
</style>

Incorrect dialog style on old android versions

I have so style for alert dialogs:
<style name="Theme.Paper" parent="Theme.AppCompat.Light.NoActionBar">
<!-- customize the color palette -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="android:alertDialogStyle">#style/Theme.Paper.AlertDialogStyle</item>
<item name="android:alertDialogTheme">#style/Theme.Paper.AlertDialog</item>
</style>
<style name="Theme.Paper.Toolbar" parent="Theme.Paper">
<item name="android:textColorPrimary">#color/white</item>
<item name="android:textColorSecondary">#color/white</item>
</style>
<style name="Theme.Paper.AlertDialogStyle" parent="android:Theme.Black">
<item name="android:fullDark">#color/white</item>
<item name="android:topDark">#color/white</item>
<item name="android:centerDark">#color/white</item>
<item name="android:bottomDark">#color/white</item>
<item name="android:fullBright">#color/white</item>
<item name="android:centerBright">#color/white</item>
<item name="android:bottomBright">#color/white</item>
<item name="android:bottomMedium">#color/white</item>
<item name="android:centerMedium">#color/white</item>
</style>
<style name="Theme.Paper.AlertDialog.Title">
<item name="android:maxLines">2</item>
<item name="android:scrollHorizontally">true</item>
</style>
<style name="Theme.Paper.AlertDialog.TextAppearanceMedium">
<!-- Set text size and color of message here -->
<item name="android:textSize">16sp</item>
<item name="android:textColor">#color/black_54</item>
</style>
<style name="Theme.Paper.AlertDialog.TextAppearanceLarge">
<!-- Set text size and color of title -->
<item name="android:textSize">20sp</item>
<item name="android:textColor">#color/black_87</item>
</style>
<style name="Theme.Paper.AlertDialog" parent="android:Theme.Black">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowTitleStyle">#style/Theme.Paper.AlertDialog.Title</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowMinWidthMajor">#android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">#android:dimen/dialog_min_width_minor</item>
<item name="android:windowIsFloating">true</item>
<item name="android:textAppearanceMedium">#style/Theme.Paper.AlertDialog.TextAppearanceMedium</item>
<item name="android:textAppearanceLarge">#style/Theme.Paper.AlertDialog.TextAppearanceLarge</item>
<item name="android:buttonBarStyle">#style/Theme.Paper.AlertDialog.ButtonBar</item>
<item name="android:buttonBarButtonStyle">#style/Theme.Paper.FlatButton</item>
</style>
<style name="Theme.Paper.FlatButton">
<!-- Set background drawable and text size of the buttons here -->
<item name="android:background">#drawable/bg_dialog_button</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">#color/primary</item>
<item name="android:layout_height">36dp</item>
<item name="android:maxHeight">36dp</item>
<item name="android:minHeight">36dp</item>
<item name="android:minWidth">64dp</item>
<item name="android:textAllCaps">true</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingRight">8dp</item>
<item name="android:layout_marginLeft">4dp</item>
<item name="android:layout_marginRight">4dp</item>
</style>
<style name="Theme.Paper.AlertDialog.ButtonBar">
<!-- Define a background for the button bar and a divider between the buttons here -->
<item name="android:divider">#android:color/transparent</item>
<item name="android:dividerPadding">0dp</item>
<item name="android:showDividers">none</item>
<item name="android:background">#color/white</item>
<item name="android:layout_height">48dp</item>
<item name="android:gravity">center_vertical|right</item>
</style>
It looks normal on Android 4.x, but on Android 2.x devices I get just white dialog window with buttons (all text is white with default sizes)
How I can fix it?
P.S. Please, help me! I cannot publish my app because of this only...

How do I fix my navigation bar which appears to be shifted in nexus devices?

I have a navigation bar at the top of my app. It look fine if galaxy/htc devices as follows:
However, in nexus devices it seems to shift a little as follows, not sure why:
Here is my code for the same : (actionbar.xml) :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:foo="http://schemas.android.com/apk/res/com.justin.abc"
android:id="#+id/title_information_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#27272b"
android:fillViewport="true" >
<com.justin.abc.utils.FontTextView
android:id="#+id/actionbar_title"
android:layout_width="wrap_content"
android:layout_height="#dimen/actionbar_title_height"
android:layout_marginTop="#dimen/actionbar_title_topmargin"
android:layout_marginLeft="#dimen/common_left_padding"
android:text="#string/title_about"
foo:customFont="proxima-nova-regular-Regular.ttf"
android:textColor="#color/white"
android:textSize="#dimen/actionbar_title" />
<Button
android:id="#+id/button_done"
android:layout_width="wrap_content"
android:layout_height="#dimen/done_button_height"
android:layout_marginTop="#dimen/done_button_topmargin"
android:layout_alignParentRight="true"
android:layout_marginLeft="#dimen/done_button_leftmargin"
android:layout_marginRight="#dimen/done_button_rightmargin"
android:background="#drawable/done_cancel_button"
android:text="#string/menu_done"
android:textColor="#drawable/done_button_text"
android:textSize="#dimen/button_text" />
<View
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_marginTop="#dimen/actionbar_view_margintop"
android:background="#color/black"
android:visibility="visible" />
</RelativeLayout>
Any clues how I can fix the same so it works well in all devices? Thanks!
This is the associated theme:
<style name="AppTheme" parent="#style/Theme.Sherlock"></style>
<style name="AppTheme.NoActionBar" parent="#style/Theme.Sherlock.NoActionBar"></style>
<style name="AppBaseTheme.NoActionBar" parent="AppTheme.NoActionBar"></style>
<!-- Although this is doing exactly what AppBaseTheme is doing,
it fixes the initialization display of the icon being truncated -->
<style name="ABTheme" parent="AppTheme">
<item name="homeAsUpIndicator">#null</item>
<item name="selectableItemBackground">#drawable/btn_selector_home_icon</item>
</style>
<style name="AppBaseTheme" parent="AppTheme">
<item name="homeAsUpIndicator">#null</item>
<item name="selectableItemBackground">#drawable/btn_selector_home_icon</item>
<item name="android:listViewStyle">#style/ListViewAppTheme</item>
<item name="android:listViewWhiteStyle">#style/ListViewAppTheme.White</item>
<item name="android:spinnerItemStyle">#style/SpinnerItemAppTheme</item>
</style>
<style name="ListViewAppTheme" parent="android:Widget.ListView">
<item name="android:listSelector">#drawable/list_selector_holo_light</item>
</style>
<style name="ListViewAppTheme.White" parent="android:Widget.ListView.White">
<item name="android:listSelector">#drawable/list_selector_holo_light</item>
</style>
<style name="SpinnerItemAppTheme" parent="android:TextAppearance.Widget.TextView.SpinnerItem">
<item name="android:textColor">#000000</item>
</style>
<style name="abc.TextView" parent="android:Widget.Holo.TextView"></style>
<style name="T1UserContactCountry">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#cccccc</item>
<item name="android:textSize">#dimen/title</item>
<item name="android:paddingLeft">#dimen/common_left_padding</item>
<item name="android:layout_gravity">left</item>
</style>
<style name="T1UserContactPhone">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#color/abs__holo_blue_light</item>
<item name="android:textSize">#dimen/title</item>
<item name="android:onClick">onPhoneNumberClicked</item>
<item name="android:paddingRight">#dimen/common_right_padding</item>
<item name="android:layout_gravity">right</item>
<item name="android:clickable">true</item>
</style>
<style name="T1TableRowSeparator">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
</style>
<style name="T1ViewSeparator">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">2dp</item>
<item name="android:background">#color/header_grey</item>
<item name="android:layout_span">2</item>
</style>
<style name="abc.TextView.ListsTextView">
<item name="android:ellipsize">end</item>
<item name="android:gravity">right</item>
<item name="android:singleLine">true</item>
<item name="android:background">#android:color/transparent</item>
</style>
<style name="abc.TextView.ListsTextView.Header">
<item name="android:paddingTop">2dp</item>
<item name="android:textSize">15sp</item>
<item name="android:background">#android:color/transparent</item>
</style>
<style name="CustomTheme">
<item name="android:windowBackground">#color/custom_theme_color</item>
<item name="android:colorBackground">#color/custom_theme_color</item>
</style>
<style name="abc.TextView.ListsTextView.Value">
<item name="android:textSize">15sp</item>
<item name="android:background">#android:color/transparent</item>
</style>
<style name="abc.TextView.NavigationItem">
<item name="android:clickable">true</item>
<item name="android:padding">3dp</item>
<item name="android:textSize">20sp</item>
<item name="android:background">#color/black</item>
</style>
<style name="search_autosuggest_header" parent="android:Widget.Holo.TextView">
<item name="android:paddingBottom">5dp</item>
<item name="android:paddingLeft">3dp</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">#color/search_autosuggest_header_text</item>
<item name="android:background">#drawable/background_search_auto_suggest_header</item>
<item name="android:textStyle">bold</item>
</style>
<style name="abc.TextView.Preferences">
<item name="android:padding">8dp</item>
</style>
<style name="abc.TextView.Preferences.Title">
<item name="android:background">#color/black</item>
<item name="android:textColor">#color/background_preferences_item</item>
</style>
<style name="abc.TextView.Preferences.Item">
<item name="android:background">#color/background_preferences_item</item>
<item name="android:textColor">#color/background_preferences_title</item>
</style>
<style name="abc.TextView.Preferences.Item.clickable">
<item name="android:background">#drawable/background_preferences_layout_selector</item>
<item name="android:textColor">#color/background_preferences_title</item>
</style>
<style name="abc.Button.Toggle" parent="android:Widget.Holo.Button.Toggle">
<item name="android:button">#null</item>
<item name="android:textOff"></item>
<item name="android:textOn"></item>
<item name="android:background">#drawable/toggle_selector_abc</item>
</style>
<style name="LoginEditText" parent="#android:style/Widget.EditText">
<item name="#android:textColor">#color/textbox_hint</item>
<item name="#android:textSize">16sp</item>
<item name="#android:maxLines">1</item>
<item name="#android:fontFamily">Roboto-Regular</item>
</style>
<style name="MenuDialogAnimation">
<item name="android:windowEnterAnimation">#anim/grow_from_topright_to_bottomleft</item>
<item name="android:windowExitAnimation">#anim/shrink_from_bottomleft_to_topright</item>
</style>
<style name="MenuDialogAnimationLeft">
<item name="android:windowEnterAnimation">#anim/grow_from_topleft_to_bottomright</item>
<item name="android:windowExitAnimation">#anim/shrink_from_bottomright_to_topleft</item>
</style>
<style name="BriefcaseMenuDialogAnimation">
<item name="android:windowEnterAnimation">#android:anim/fade_in</item>
<item name="android:windowExitAnimation">#android:anim/fade_out</item>
</style>
<style name="ButtonText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#ffffff</item>
<item name="android:gravity">center</item>
<item name="android:layout_margin">3dp</item>
<item name="android:textSize">30dp</item>
<item name="android:shadowColor">#000000</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">2</item>
<item name="android:paddingLeft">15dp</item>
<item name="android:paddingRight">15dp</item>
</style>
<style name="Divider">
<item name="android:divider">#drawable/divider</item>
<item name="android:dividerHeight">1px</item>
</style>
<style name="related_buttons" parent="android:Widget.Holo.TextView">
<item name="android:clickable">true</item>
<item name="android:gravity">center_vertical|left</item>
<item name="android:layout_marginBottom">3dp</item>
<item name="android:layout_marginTop">3dp</item>
<item name="android:paddingLeft">12dp</item>
<item name="android:paddingRight">12dp</item>
<item name="android:visibility">gone</item>
<item name="android:drawableRight">#drawable/arrow_chevron_selector</item>
</style>
In my manifest I am referencing it as follows:
<application
android:name=".abcApplication"
android:allowBackup="true"
android:icon="#drawable/abc_launcher"
android:label="#string/app_long_name"
android:theme="#style/ABTheme" android:debuggable="false">
Here's my java code:
public void manageActionBar() {
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.actionbar_no_button);
getSupportActionBar().setDisplayShowHomeEnabled(false);
final TextView titleView = (TextView) actionBar.getCustomView().findViewById(R.id.actionbar_title);
titleView.setText(R.string.personal);
}
The reason this is not working is because this is not the way you customize the Action Bar, I suggest reading about how to customize the Action Bar here.
What you want to do basically is define a theme for your application, as you stated in the comments you want to change the look based on your project requirements.
Here is the example from the article I've linked above:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="android:actionMenuTextColor">#color/actionbar_text</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="actionBarTabTextStyle">#style/TabTextStyle</item>
<item name="actionMenuTextColor">#color/actionbar_text</item>
</style>
<!-- general styles for the action bar -->
<style name="MyActionBar"
parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/TitleTextStyle</item>
<item name="android:background">#drawable/actionbar_background</item>
<item name="android:backgroundStacked">#drawable/actionbar_background</item>
<item name="android:backgroundSplit">#drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/TitleTextStyle</item>
<item name="background">#drawable/actionbar_background</item>
<item name="backgroundStacked">#drawable/actionbar_background</item>
<item name="backgroundSplit">#drawable/actionbar_background</item>
</style>
<!-- action bar title text -->
<style name="TitleTextStyle"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
</style>
<!-- action bar tab text -->
<style name="TabTextStyle"
parent="#style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">#color/actionbar_text</item>
</style>
</resources>
After doing that, you can customize the look of your Action Bar to look just the way you want it to (Make sure you set the colors the right way).
I'm having some problem with the ActionBar as well. And the problems only appears on Nexus 7 (I don't have other Nexus). I placed my custom view inside the action bar, to completely cover it up (because it can't be configure to the way I want).
LayoutParams layout = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT );
LayoutInflater inflator = (LayoutInflater) getSystemService( Context.LAYOUT_INFLATER_SERVICE );
View v = inflator.inflate( R.layout.my_actionbar_layout, null );
getActionBar().setDisplayShowCustomEnabled( true );
getActionBar().setDisplayShowHomeEnabled( false );
getActionBar().setCustomView( v, layout );
However, there is a gap on the left size and the view goes too far over the right edge of screen.
The solution, however, is very simple:
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
Hope this help you (and others).
Credits:
I found the answer from this page:
http://answer.techwikihow.com/1352928/actionbar-customview-extra-padding-cannot-removed.html

ActionBar has correct colors in Android 4.2, wrong colors in Android 2.3

I'm using ActionBarSherlock and HoloEverywhere in my app. I used the ActionBar Style Generator to generate my styles and then modified them a bit by hand for text colors, etc.
I'm having a problem where my ActionBar looks correct on my Android 4.2 device (that is, orange with white text), but on my Android 2.3 device the ActionBar is black with grey text.
Does anyone know what might cause this?
<style name="Theme.MyApp" parent="#style/Holo.Theme.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_MyApp</item>
<item name="android:popupMenuStyle">#style/PopupMenu.MyApp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.MyApp</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.MyApp</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.MyApp</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.MyApp</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_MyApp</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_MyApp</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.MyApp</item>
<!-- <item name="android:textColorPrimary">#FFFFFF</item> -->
<item name="android:spinnerDropDownItemStyle">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle</item>
</style>
<style name="ActionBar.Solid.MyApp" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_solid_MyApp</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_MyApp</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_MyApp</item>
<item name="android:progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="android:titleTextStyle">#style/ActionBar.Solid.MyApp.TitleTextStyle</item>
</style>
<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle" parent="#android:style/Widget.Holo.DropDownItem.Spinner">
<item name="android:textAppearance">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle</item>
</style>
<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle" parent="#android:style/Widget">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">18sp</item>
</style>
<style name="ActionBar.Solid.MyApp.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">18sp</item>
<!-- <item name="android:fontFamily">sans-serif-medium</item> -->
</style>
<style name="ActionBar.Transparent.MyApp" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/ab_transparent_MyApp</item>
<item name="android:progressBarStyle">#style/ProgressBar.MyApp</item>
</style>
<style name="PopupMenu.MyApp" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_MyApp</item>
</style>
<style name="DropDownListView.MyApp" parent="#android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_MyApp</item>
</style>
<style name="ActionBarTabStyle.MyApp" parent="#android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_MyApp</item>
</style>
<style name="DropDownNav.MyApp" parent="#android:style/Widget.Holo.Spinner">
<item name="android:background">#drawable/spinner_background_ab_MyApp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_MyApp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_MyApp</item>
</style>
<style name="ProgressBar.MyApp" parent="#android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_MyApp</item>
</style>
<style name="ActionButton.CloseMode.MyApp" parent="#android:style/Widget.Holo.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_MyApp</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.MyApp.Widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu.MyApp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.MyApp</item>
</style>
--------------- EDIT ----------------------
So I'm now having a problem where the action bar is taking up the entire screen on the Android 2.3 device (but works fine on Android 4.2). Do I need to remove the "android:" from the parent attributes?
parent="#android:style/Widget.Holo.ListPopupWindow"
When I tried this, Eclipse was unable to find the theme.
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.MyApp" parent="#style/Holo.Theme.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_MyApp</item>
<item name="android:popupMenuStyle">#style/PopupMenu.MyApp</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.MyApp</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.MyApp</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.MyApp</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.MyApp</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_MyApp</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_MyApp</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.MyApp</item>
<!-- <item name="android:textColorPrimary">#FFFFFF</item> -->
<item name="android:spinnerDropDownItemStyle">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle</item>
<item name="actionBarItemBackground">#drawable/selectable_background_MyApp</item>
<item name="popupMenuStyle">#style/PopupMenu.MyApp</item>
<item name="dropDownListViewStyle">#style/DropDownListView.MyApp</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.MyApp</item>
<item name="actionDropDownStyle">#style/DropDownNav.MyApp</item>
<item name="actionBarStyle">#style/ActionBar.Solid.MyApp</item>
<item name="actionModeBackground">#drawable/cab_background_top_MyApp</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_MyApp</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.MyApp</item>
<!-- <item name="textColorPrimary">#FFFFFF</item> -->
<item name="spinnerDropDownItemStyle">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle</item>
</style>
<style name="ActionBar.Solid.MyApp" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/ab_solid_MyApp</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_MyApp</item>
<item name="android:backgroundSplit">#drawable/ab_bottom_solid_MyApp</item>
<item name="android:progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="android:titleTextStyle">#style/ActionBar.Solid.MyApp.TitleTextStyle</item>
<item name="background">#drawable/ab_solid_MyApp</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_MyApp</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_MyApp</item>
<item name="progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="titleTextStyle">#style/ActionBar.Solid.MyApp.TitleTextStyle</item>
</style>
<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle" parent="#android:style/Widget.Holo.DropDownItem.Spinner">
<item name="android:textAppearance">#style/ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle</item>
</style>
<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle" parent="#android:style/Widget">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">18sp</item>
</style>
<style name="ActionBar.Solid.MyApp.TitleTextStyle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">18sp</item>
<!-- <item name="android:fontFamily">sans-serif-medium</item> -->
</style>
<style name="ActionBar.Transparent.MyApp" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/ab_transparent_MyApp</item>
<item name="android:progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="background">#drawable/ab_transparent_MyApp</item>
<item name="progressBarStyle">#style/ProgressBar.MyApp</item>
</style>
<style name="PopupMenu.MyApp" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_MyApp</item>
</style>
<style name="DropDownListView.MyApp" parent="#android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_MyApp</item>
</style>
<style name="ActionBarTabStyle.MyApp" parent="#android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_MyApp</item>
<item name="background">#drawable/tab_indicator_ab_MyApp</item>
</style>
<style name="DropDownNav.MyApp" parent="#android:style/Widget.Holo.Spinner">
<item name="android:background">#drawable/spinner_background_ab_MyApp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_MyApp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_MyApp</item>
<item name="background">#drawable/spinner_background_ab_MyApp</item>
</style>
<style name="ProgressBar.MyApp" parent="#android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_MyApp</item>
</style>
<style name="ActionButton.CloseMode.MyApp" parent="#android:style/Widget.Holo.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_MyApp</item>
<item name="background">#drawable/btn_cab_done_MyApp</item>
</style>
</resources>
As per the official docs, you need to also declare the attributes without the android: namespace. In your case, those attributes are only getting applied to the native implementation.

Categories

Resources