remove unwanted spacing in Action bar tabs - android

I got a problem with action bar tab spacing.Below I am showing the screenshot of action bar tabs.
Below I am posted the codes relevant to this issue.
MainActivity.java:
ActionBar.Tab tab = actionBar.newTab()
.setText("Tab1")
.setTabListener(
new TabListener(this, Home.class.getName()));
View tabView = inflater.inflate(R.layout.fragment_home, null);
tabView.setBackgroundResource(R.drawable.gradient_shape); // set custom color
tab.setCustomView(tabView);
actionBar.addTab(tab);
drawable/gradient_shape.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="4dp" />
<stroke
android:width="1dp"
android:color="#0078a5" />
<gradient
android:angle="90"
android:endColor="#00adee"
android:startColor="#0078a5" />
<padding
android:bottom="25dp"
android:left="50dp"
android:right="50dp"
android:top="25dp" />
</shape>
styles.xml:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
</style>
</resources>
values-v11/styles.xml:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
</resources>
values-v14/styles.xml:
<resources>
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
</resources>
Manifest:
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light.DarkActionBar" >
<activity
android:name="com.smart.activity.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I need to remove the unwanted spacing between the tabs.The Tabs have to get merge one by one.And also the Action bar tab name wasn't displayed.Anybody can help me with this.Thank you.

Added this in values/styles.xml solved my problem:
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarTabStyle">#style/CustomTabWidget</item>
<item name="android:actionBarTabBarStyle">#style/MyActionBarTabBar</item>
</style>
<style name="CustomTabWidget" parent="#android:style/Widget.TabWidget">
<item name="android:textAppearance">#style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" parent="#android:style/TextAppearance.Widget.TabWidget">
<item name="android:textSize">20sp</item>
<item name="android:textAppearance">#android:style/TextAppearance.Medium</item>
<item name="android:gravity">center</item>
<item name="android:paddingLeft">50dp</item>
<item name="android:paddingRight">20dp</item>
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="MyActionBarTabBar">
<item name="android:gravity">center</item>
</style>
</resources>
Then in Manifest:
I set a theme like this android:theme="#style/MyTheme" in application element.

Related

android You cannot combine custom titles with other title features

I am using Android Studio 3.2 and Android API 23 develop the app, when I try to set a custom title bar it display the error You cannot combine custom titles with other title features.
I google the the error and try some answers on so, but it can't solve the problem, I am stucked.
the code is as following,
the manifest code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shashiwang.shashiapp">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity" android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
the styles:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="windowNoTitle">true</item>
<!--<item name="windowActionBar">false</item>-->
</style>
<style name="TitleBarLayout" >
<item name="android:background">#color/colorTitleBarBg</item>
<item name="android:layout_height">#dimen/title_bar_height</item>
<item name="android:layout_width">match_parent</item>
</style>
<style name="TitleBarTitle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:color">#color/colorTitleBarTitle</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:text">#string/app_name</item>
<item name="android:textSize">#dimen/title_bar_title_font_size</item>
<item name="android:textStyle">bold</item>
</style>
<style name="TitleBarContactLayout">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:orientation">vertical</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:gravity">center</item>
<item name="android:layout_marginRight">10dp</item>
</style>
<style name="TitleBarContactIcon">
<item name="android:layout_width">#dimen/title_bar_contact_icon_width</item>
<item name="android:layout_height">#dimen/title_bar_contact_icon_height</item>
<item name="android:src">#drawable/ic_contact</item>
</style>
<style name="TitleBarContactText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:text">#string/title_bar_contact_text</item>
<item name="android:textSize">#dimen/title_bar_contact_font_size</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
the layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/titleBarContainer"
style="#style/TitleBarLayout">
<TextView
android:id="#+id/TitleBarTitle"
style="#style/TitleBarTitle" />
<LinearLayout
android:id="#+id/TitleBarContactContainer"
style="#style/TitleBarContactLayout">
<ImageView
android:id="#+id/titleBarContactIcon"
style="#style/TitleBarContactIcon" />
<TextView
android:id="#+id/TitleBarContactText"
style="#style/TitleBarContactText" />
</LinearLayout>
</RelativeLayout>
the activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar_layout);
}

Change AppTheme dynamically

Goal: I want to allow user to change the color theme of my app.
Themes (styles.xml):
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/indigoColorPrimary</item>
<item name="colorPrimaryDark">#color/indigoColorPrimaryDark</item>
<item name="colorAccent">#color/indigoColorAccent</item>
<item name="android:statusBarColor">#color/indigoColorPrimaryDark</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.FullScreen">
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme.MainActivity">
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="AppTheme.SearchActivity">
<item name="android:statusBarColor">#android:color/darker_gray</item>
<item name="android:windowAnimationStyle">#null</item>
</style>
<!-- Colors -->
<style name="AppTheme.Indigo">
<item name="colorPrimary">#color/indigoColorPrimary</item>
<item name="colorPrimaryDark">#color/indigoColorPrimaryDark</item>
<item name="colorAccent">#color/indigoColorAccent</item>
<item name="android:statusBarColor">#color/indigoColorPrimaryDark</item>
</style>
<style name="AppTheme.Blue">
<item name="colorPrimary">#color/blueColorPrimary</item>
<item name="colorPrimaryDark">#color/blueColorPrimaryDark</item>
<item name="colorAccent">#color/blueColorAccent</item>
<item name="android:statusBarColor">#color/blueColorPrimaryDark</item>
</style>
<style name="AppTheme.Red">
<item name="colorPrimary">#color/redColorPrimary</item>
<item name="colorPrimaryDark">#color/redColorPrimaryDark</item>
<item name="colorAccent">#color/redColorAccent</item>
<item name="android:statusBarColor">#color/redColorPrimaryDark</item>
</style>
<!-- some other colors -->
</resources>
As you can see, I have the main theme AppTheme that as a default color ("indigo").
I have three other themes FullScreen, MainActivity and SearchActivity that derive from AppTheme, and then colors themes.
AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.superbstudios.reportnote">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SignInActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.FullScreen" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SearchActivity"
android:label=""
android:theme="#style/AppTheme.SearchActivity"
android:windowSoftInputMode="stateVisible" />
<activity
android:name=".SettingsActivity"
android:label="#string/title_activity_settings"
android:theme="#style/AppTheme" />
<activity
android:name=".GuideActivity"
android:label="#string/title_activity_guide"
android:theme="#style/AppTheme" />
</application>
</manifest>
Now, only SignInActiviy, MainActivity and SearchActivity has their own themes, the other activity (also application) has AppTheme.
What I do: I create a BaseActivity class, and all activity extend this class.In BaseActivity in onCreate method before super declaration I use this code to change color theme:
setTheme(R.style.AppTheme_Red);
Problem: This code change the theme for all activity and also for SignInActiviy, MainActivity and SearchActivity that needs a different theme.
I don't know if the colors theme are useful.
The only things i want is to change the AppTheme colors like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/redColorPrimary</item>
<item name="colorPrimaryDark">#color/redColorPrimaryDark</item>
<item name="colorAccent">#color/redColorAccent</item>
<item name="android:statusBarColor">#color/redColorPrimaryDark</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
So, what I have to do to change colors of my app?
I solved it by changing styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/indigoColorPrimary</item>
<item name="colorPrimaryDark">#color/indigoColorPrimaryDark</item>
<item name="colorAccent">#color/indigoColorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.FullScreen">
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme.MainActivity">
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="AppTheme.SearchActivity">
<item name="android:statusBarColor">#android:color/darker_gray</item>
<item name="android:windowAnimationStyle">#null</item>
</style>
<!-- Colors -->
<style name="Indigo">
<item name="colorPrimary">#color/indigoColorPrimary</item>
<item name="colorPrimaryDark">#color/indigoColorPrimaryDark</item>
<item name="colorAccent">#color/indigoColorAccent</item>
</style>
<style name="Blue">
<item name="colorPrimary">#color/blueColorPrimary</item>
<item name="colorPrimaryDark">#color/blueColorPrimaryDark</item>
<item name="colorAccent">#color/blueColorAccent</item>
</style>
<style name="Red">
<item name="colorPrimary">#color/redColorPrimary</item>
<item name="colorPrimaryDark">#color/redColorPrimaryDark</item>
<item name="colorAccent">#color/redColorAccent</item>
</style>
</resources>
And in my BaseActivity i use this code:
getTheme().applyStyle(R.style.Blue, true);
Referenced to the comment
I'll answer by taking Red color as an example
If you only want to change the colorPrimary then keep only it.
<style name="AppTheme.Red">
<item name="colorPrimary">#color/redColorPrimary</item>
</style>
Other wise create two themes for Red color. One with status bar color and other inheriting that with transparent status bar.
<style name="AppTheme.Red">
<item name="colorPrimary">#color/redColorPrimary</item>
<item name="colorPrimaryDark">#color/redColorPrimaryDark</item>
<item name="colorAccent">#color/redColorAccent</item>
<item name="android:statusBarColor">#color/redColorPrimaryDark</item>
</style>
<style name="AppTheme.RedTransparentStatus" parent="AppTheme.Red>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
So if you want status bar to transparent you can set the second theme or else the first.
From my understanding, you want to keep the default "Indigo" color for
SignInActivity, MainActivity, SearchActivity.
Todo so inherit the relevant themes of those activities with AppTheme
<style name="AppTheme.SearchActivity" parent="AppTheme">
...
</style>

Action bar style theme generator theme not getting applied

So I used the action bar style generator to create a theme with style compatibility mode set to AppCompat. I downloaded the ZIP file and copy and pasted all the files inside my folder but the theme isn't showing up when emulator is ran.
The styles_actionstyle.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Actionstyle" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_actionstyle</item >
<item name="popupMenuStyle">#style/PopupMenu.Actionstyle</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Actionstyle</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Actionstyle</item>
<item name="actionDropDownStyle">#style/DropDownNav.Actionstyle</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Actionstyle</item>
<item name="actionModeBackground">#drawable/cab_background_top_actionstyle</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_actionstyle</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Actionstyle</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Actionstyle.Widget</item>
</style>
<style name="ActionBar.Solid.Actionstyle" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_actionstyle</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_actionstyle</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_actionstyle</item>
<item name="progressBarStyle">#style/ProgressBar.Actionstyle</item>
</style>
<style name="ActionBar.Transparent.Actionstyle" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/ab_transparent_actionstyle</item>
<item name="progressBarStyle">#style/ProgressBar.Actionstyle</item>
</style>
<style name="PopupMenu.Actionstyle" parent="#style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_actionstyle</item>
</style>
<style name="DropDownListView.Actionstyle" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_actionstyle</item>
</style>
<style name="ActionBarTabStyle.Actionstyle" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_actionstyle</item>
</style>
<style name="DropDownNav.Actionstyle" parent="#style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_actionstyle</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_actionstyle</item>
<item name="android:dropDownSelector">#drawable/selectable_background_actionstyle</item>
</style>
<style name="ProgressBar.Actionstyle" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_actionstyle</item>
</style>
<style name="ActionButton.CloseMode.Actionstyle" parent="#style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_actionstyle</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Actionstyle.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Actionstyle</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Actionstyle</item>
</style>
</resources>
The V14 version:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Actionstyle" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarItemBackground">#drawable/selectable_background_actionstyle</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Actionstyle</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Actionstyle</item>
<item name="android:actionBarTabStyle">#style/ActionBarTabStyle.Actionstyle</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Actionstyle</item>
<item name="android:actionBarStyle">#style/ActionBar.Solid.Actionstyle</item>
<item name="android:actionModeBackground">#drawable/cab_background_top_actionstyle</item>
<item name="android:actionModeSplitBackground">#drawable/cab_background_bottom_actionstyle</item>
<item name="android:actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Actionstyle</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">#style/Theme.Actionstyle.Widget</item>
</style>
<style name="ActionBar.Solid.Actionstyle" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/ab_background_textured_actionstyle</item>
<item name="android:backgroundStacked">#drawable/ab_stacked_solid_actionstyle</item>
<item name="android:backgroundSplit">#drawable/ab_background_textured_actionstyle</item>
<item name="android:progressBarStyle">#style/ProgressBar.Actionstyle</item>
</style>
<style name="ActionBar.Transparent.Actionstyle" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:background">#drawable/ab_transparent_actionstyle</item>
<item name="android:progressBarStyle">#style/ProgressBar.Actionstyle</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Actionstyle.Widget" parent="#style/Theme.AppCompat">
<item name="android:popupMenuStyle">#style/PopupMenu.Actionstyle</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Actionstyle</item>
</style>
</resources>
The manifests file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.blooddonation2" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Actionstyle" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

support actionbar menu styling

How does one style the Android ActionBar overflow menu (background color, text color, custom drawables etc.)?
I've been trying to do this with the following styles, but nothing seems to be taking any effect. Any help would be greatly appreciated.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarWidgetTheme">#style/MyActionBar</item>
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:textColor">#android:color/holo_blue_light</item>
<item name="android:actionBarItemBackground">#android:color/holo_green_light</item>
<item name="android:actionMenuTextColor">#android:color/holo_green_dark</item>
</style>
</resources>
TIA!
BTW minSdk set to 14
AndroidManifest is
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app1.app1">
<application android:allowBackup="true"
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Do you call it on AndroidManifest.xml file?
Example in my style.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/green_dark</item>
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#android:style/TextAppearance">
<item name="android:textColor">#color/white</item>
<item name="android:textStyle">bold</item>
</style>
and in menifestfile
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher1"
android:label="#string/app_name"
android:theme="#style/CustomActionBarTheme" >
<activity.....
For implement click listener, you need create option menu for this case.

Cant set Android Actionbar Background correctly

The Problem
When im setting the ActionBar Background Color the Bar looks like this:
i cant upload Images here so here is the File:
Android ActionBar Problem
My values/styles File
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="actionBarStyle">#style/ActionBarTheme</item>
</style>
<!-- Action Bar theme -->
<style name="ActionBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:background">#drawable/actionbar</item>
<item name="background">#drawable/actionbar</item>
</style>
<style name="FullscreenTheme" parent="android:style/Theme.NoTitleBar.Fullscreen">
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">#style/ButtonBar</item>
<item name="metaButtonBarButtonStyle">#style/ButtonBarButton</item>
</style>
<style name="ButtonBar">
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingRight">2dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:background">#android:drawable/bottom_bar</item>
</style>
<style name="ButtonBarButton" />
</resources>
My Manifest File
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.application"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/symbol"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.application.Main"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.application.Settings"
android:parentActivityName="com.application.Main"
android:screenOrientation="portrait"
android:theme="#style/ActionBarTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.application.Main" />
</activity>
<activity
android:name="com.application.DateList"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:theme="#style/FullscreenTheme" >
</activity>
</application>
</manifest>
I also try this but the same happened
ColorDrawable draw = new ColorDrawable(R.color.grey);
getSupportActionBar().setBackgroundDrawable(draw);
My Color Drawable
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="#color/grey" />
</shape>
getSupportActionBar().setBackgroundDrawable(draw);
should be, in your case
getSupportActionBar().setBackgroundDrawable(getResources.getDrawable(R.drawable.your_drawable_name);
The Constructor of ColorDrawable takes the int that represent the color, not the id of the color. Use instenad
ColorDrawable draw = new ColorDrawable(getResources().getColor(R.color.grey));
Edit:
about the style.xml, you need both the item with and without the android prefix:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">#style/ActionBarTheme</item>
<item name="actionBarStyle">#style/ActionBarTheme</item>
</style>
Lint is probably going to complain about it, because of the minSDK value. if it does you can add tools:ignore="NewApi" to the item with the android: prefix. For instance:
<item name="android:actionBarStyle" tools:ignore="NewApi">#style/ActionBarTheme</item>

Categories

Resources