I am making an android app and while changing themes for the design I by mistake remove the actionbar at the top.
Here is my Styles.xml :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.DesignDemo" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/ColorPrimary</item>
<item name="colorPrimaryDark">#color/ColorPrimaryDark</item>
<item name="android:windowBackground">#color/window_background</item>
<item name="colorAccent">#color/ColorPrimary</item>
<item name="android:colorBackground">#color/window_background</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
</style>
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/ColorPrimaryDark</item>
</style>
<style name="Base.Theme.DesignDemo"
parent="Theme.AppCompat.Light">
How can I make it appear again?
Related
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>
I am trying to style the TabBar using the following code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="MyTheme.Base"/>
<style name="MyTheme.Base" parent="Theme.AppCompat">
<item name="colorPrimary">#color/palette_1</item>
<item name="colorPrimaryDark">#color/palette_5</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">true</item>
<item name="android:windowBackground">#color/palette_1</item>
<item name="android:actionBarStyle">#style/MyTheme.ActionBar</item>
<item name="actionBarStyle">#style/MyTheme.ActionBar</item>
<item name="actionBarTabStyle">#style/MyTheme.ActionBarTabBar</item>
<item name="android:actionBarTabStyle">#style/MyTheme.ActionBarTabBar</item>
</style>
<style name="MyTheme.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#color/palette_5</item>
<item name="backgroundStacked">#color/palette_5</item>
<item name="backgroundSplit">#color/palette_5</item>
</style>
<style name="MyTheme.ActionBarTabBar" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#color/palette_5</item>
</style>
<style name="MyTheme.NoTitleBar" parent="MyTheme">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
Whewre palette_1 is green and palette_5 is blue for example.
The actionBar is blue but the tabbar stays the color that i define in android:windowBackground, which is green.
This is the code i came up with after searching numerous topics. But yet it seems to be conflicting somewhere.
I am having trouble finding out why the title in my action bar appears black, this only happens on an emulator with Android 4.1.1, which should be API 15.
Here is my default styles.xml
<resources>
<!-- Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
and here is the styles from values-v15 and values-v14
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:actionOverflowButtonStyle">#style/OverFlow</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- Styles -->
<style name="OverFlow" parent="#android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">#drawable/ic_action_about</item>
<item name="android:textColor">#color/white</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/action_bar_background</item>
<item name="android:textColor">#color/white</item>
</style>
what would be the problem?
Try this:
<style name="TitleTextColor">
<item name="android:text">#string/app_name</item>
<item name="android:textSize">10sp</item>
<item name="android:textColor">#a23421</item>
</style>
Edit:(new) Put this in the styles.XML
<?xml version="1.0" encoding="utf-8"?>
<resources>
<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/red</item>
</style>
</resources>
For White text:
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#f00</item>
<item name="android:titleTextStyle">#style/MyTextAppearance</item>
</style>
<style name="MyTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#ffffff</item>
</style>
I don't want to create any custom layout for app label, just want to change it's color to white (now it's black). How could I do that?
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/bg_blue_solid_onclick</item>
//////CHANGE label color
</style>
</resources>
styles.xml
<style name="MyTheme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#FF9D21</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</style>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
For more info
https://developer.android.com/training/basics/actionbar/styling.html#CustomText
Snap
Edit : For making it bold
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
<item name="android:textStyle">bold</item>
</style>
None of the previous answers worked for me, so I'm showing the one that worked in my case.
<style name="AppThemeCustom" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#android:color/black</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="android:windowBackground">#android:color/white</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyTitleTextStyle</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/MyTitleTextStyle</item>
</style>
<style name="MyTitleTextStyle"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/black</item>
</style>
I wish if you find yourself in my situation this solution save your day. LOL
You need to style the android:titleTextStyle in your ActionBar.
<style name="MyActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">#style/MyTextTitle</item>
</style>
<style name="MyTextTitle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
You can see this in Android Documentation: Customize the Text Color in ActionBar
Hope this helps.
in styles.xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
in toolbar
android:theme="#style/AppTheme.AppBarOverlay"
How can I remove this white background? It only appers in tablets...
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Light"></style>
<style name="AppTheme" parent="AppBaseTheme"></style>
<style name="MyTheme" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
<item name="android:actionModeBackground">#drawable/bg_actionbar</item>
<item name="actionModeBackground">#drawable/bg_actionbar</item>
<item name="actionModeCloseDrawable">#drawable/abs__ic_cab_done_holo_dark</item>
<item name="android:windowContentOverlay">#null</item>
<!--<item name="android:homeAsUpIndicator">#drawable/icon_actionbar_back</item>-->
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/bg_actionbar</item>
<item name="android:background">#drawable/bg_actionbar</item>
</style>
</resources>
Thanks for your time.