I have what seems to be a problem I can not solve.
protected void onCreate(Bundle savedInstanceState) {
// comments describe what happens
super.onCreate(savedInstanceState);
Boolean customTitleSupported = this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
// crash at underneath line
try
{
setContentView(R.layout.myactivity);
}
catch (Exception e)
{
// You cannot combine custom titles with other title features
}
// never gets to underneath line
if customTitleSupported {
this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.override_titlebar);
}
}
...
I use the android-support-v4.jar library
requestWindowFeature(Window.FEATURE_NO_TITLE); does not cause any problems.
...
From AndroidManifest.xml file
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17"
/>
<application
android:allowBackup="true"
android:icon="#drawable/replace__logo__app_256_256"
android:label="#string/MicAppName"
android:theme="#style/MicTheme"
android:name="com.example.app.MicApp"
>
From styles.xml
<style name="AppBaseTheme" parent="android:Theme">
<item name="android:windowNoTitle">false</item>
</style>
From my_theme_support.xml
<style name="MicWindowTitleBackground">
<item name="android:background">#android:color/white</item>
<item name="android:padding">0px</item>
</style>
<style name="MicWindowTitleTextAppearance">
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold|italic</item>
</style>
<style name="MicWindowTitle">
<item name="android:textAppearance">#style/MicWindowTitleTextAppearance</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">0</item>
<item name="android:shadowRadius">5</item>
<item name="android:shadowColor">#1155CC</item>
</style>
From my_theme.xml
<style name="MicTheme" parent="AppBaseTheme">
<item name="android:windowTitleSize">44dip</item>
<item name="android:windowTitleBackgroundStyle">#style/MicWindowTitleBackground</item>
<item name="android:windowTitleStyle">#style/MicWindowTitle</item>
</style>
...
And finally override_titlebar.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<ImageView android:id="#+id/myTitleLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/replace__logo__app_256_256">
>
</ImageView>
<TextView
android:id="#+id/myTitleText"
android:text="#string/dotdotdot"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
I had missed I had a separate styles.xml for never Android phones which used
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
Replacing that with
<style name="AppBaseTheme" parent="android:Theme.Light">
has made it work
Related
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);
}
I am using an image button on ListView which shows a popup menu when clicked.
But the problem is that items are not visible.
This is how menu looks.I can see white text on menu in this image but on mobile screen it is invisible.
This is styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:colorBackground">#color/colorPrimary</item>
<item name="android:textColorPrimary">#android:color/black</item>
<item name="android:textColorSecondary">#fcfcfc</item>
<item name="android:actionMenuTextColor">#color/black</item>
</style>
<style name="itemTextStyle.AppTheme" parent="#android:style/TextAppearance.Widget.IconMenu.Item">
<item name="android:textColor">#android:color/black</item>
<item name="android:colorBackground">#color/colorPrimary</item>
</style>
<!-- LoginCreateText -->
<style name="LoginCreateText">
<item name="android:textSize">#dimen/login_buttons_text_size</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:layout_margin">2dp</item>
</style>
<!-- LoginCreateTextButton -->
<style name="LoginCreateTextButton">
<item name="android:textSize">#dimen/login_buttons_text_size</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:layout_margin">2dp</item>
<item name="android:clickable">true</item>
</style>
<style name="HintText">
<item name="android:textSize">0dp</item>
</style>
<style name="FAB">
<item name="android:layout_margin">0dp</item>
<item name="fabSize">normal</item>
<item name="rippleColor">#android:color/white</item>
<item name="backgroundTint">#color/colorAccent</item>
</style>
<style name="ListItemText">
<item name="android:textColor">#color/light_black</item>
<item name="android:textSize">#dimen/list_item_text_size</item>
<item name="android:layout_margin">2dp</item>
</style>
</resources>
This is themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Widget.Button.Login" parent="android:Widget.Button">
<item name="android:paddingLeft">18dp</item>
<item name="android:paddingRight">16dp</item>
<item name="android:textSize">#dimen/login_buttons_text_size</item>
<item name="android:layout_gravity">center</item>
<item name="android:background">#color/colorPrimary</item>
</style>
<style name="Toolbar" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:itemTextAppearance">#style/itemTextStyle.AppTheme</item>
<item name="android:background">#color/colorPrimary</item>
<item name="android:textColorPrimary">#android:color/white</item>
</style>
<style name="CustomTheme.Dialog" parent="Theme.AppCompat.Light.Dialog"/>
</resources>
This is the menu which I am trying to display.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
app:popupTheme="#style/itemTextStyle.AppTheme">
<item
android:id="#+id/action_edit"
android:title="#string/action_edit" />
<item
android:id="#+id/action_delete"
android:title="#string/action_delete"/>
<item
android:id="#+id/action_assign"
android:title="#string/action_assign"
android:checkable="true"/>
<item
android:id="#+id/action_mark"
android:title="#string/action_mark"
android:enabled="false"/>
</menu>
This is layout file for Quiz Fragment.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rl_fragment_quiz_lists"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey"
app:popupTheme="#style/itemTextStyle.AppTheme"
tools:context=".ui.fragments.QuizFragment">
<include layout="#layout/single_active_list" />
<ListView
android:id="#+id/list_view_active_lists"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
<android.support.design.widget.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/fab"
style="#style/FAB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:onClick="showAddQuizDialog"
android:src="#drawable/ic_add_quiz"
app:borderWidth="0dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp">
<!--app:rippleColor="#android:color/white" /> -->
</android.support.design.widget.FloatingActionButton>
</RelativeLayout>
This is the layout file of the activity in which this fragment is displayed.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey"
android:orientation="vertical">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="#style/Toolbar" />
<android.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/Toolbar" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
I have tried many solutions that were asked before ( all were about toolbar menu) but none worked for me.
I defined a new style in styles.xml
<style name="itemTextStyle.AppTheme" parent="#android:style/TextAppearance.Widget.IconMenu.Item">
<item name="android:textColor">#android:color/black</item>
<item name="android:colorBackground">#color/colorPrimary</item>
and included it in AppTheme which didn't work.then I included it in toolbar style, menu layout, QuizFragment layout but items were still invisible.How to change the background color or item color of menu to fix this, any one will work.
Try this
style.xml
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat">
<item name="android:actionOverflowButtonStyle">#style/OverflowButton</item>
<item name="actionOverflowButtonStyle">#style/OverflowButton</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:dropDownListViewStyle">#style/PopupMenuListView</item>
<item name="dropDownListViewStyle">#style/PopupMenuListView</item>
<item name="actionOverflowMenuStyle">#style/OverflowMenu</item>
<item name="actionBarDivider">#null</item>
<!-- OverFlow Menu Text Color -->
<item name="android:textColor">#color/black</item>
</style>
<!-- OverFlow menu Styles -->
<style name="PopupMenuListView" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:divider">#color/black</item>
<item name="android:dividerHeight">1dp</item>
<item name="android:background">#color/white</item>
</style>
<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
<!-- Required for pre-Lollipop. -->
<item name="overlapAnchor">false</item>
<!-- Required for Lollipop. -->
<item name="android:overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">4.0dip</item>
</style>
and define theme for Activity in AndroidManifest.xml
<activity
android:name=".YourActivityName"
android:theme="#style/CustomActionBarTheme"/>
I am using only two themes files (for dark, and day)
Theme.MaterialComponents.DayNight.NoActionBar.Bridge
inside them, I have only items of the same name for both day and night, but in different colors. Found (after experimenting)...that this line is a game-changer in my case (same problem as yours) for title and menu to be white, while at the same time text on popup menu is black
<item name="android:textColorSecondary">#android:color/white</item>
here is the whole file, I used only this, and trying to not hard code anything.
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Ch+++itche+++++" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
<!-- Primary brand color. -->
<item name="android:textColorSecondary">#android:color/white</item>
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryVariant">#color/primaryDarkColor</item>
<item name="colorOnPrimary">#color/primaryLightColor</item>
<item name="colorOnSurface">#color/primaryColorWhiteDay</item>
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
That is all,
Happy coding,
Nenad
In my Project i have add Library ActionBar Sherlock and create the custom theme for my project.
I have created custom theme from here.
But after applying the theme my Progress Dialog in not aligned(means not displayed in the center of screen).
Please not this issue appears in API Level 11 or above.
Here i have attached the screen shot of emulator running OS 4.2.2.
I am unable to figure out this issue...
ScreenShot ::
MyCustomTheme ::(values folder)
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Custom_ThemeSherlockLight" parent="#style/Theme.Sherlock.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_exampthemesherlocklightle</item>
<item name="popupMenuStyle">#style/PopupMenu.Custom_ThemeSherlockLight</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Custom_ThemeSherlockLight</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Custom_ThemeSherlockLight</item>
<item name="actionDropDownStyle">#style/DropDownNav.Custom_ThemeSherlockLight</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Custom_ThemeSherlockLight</item>
<item name="actionModeBackground">#drawable/cab_background_top_exampthemesherlocklightle</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_exampthemesherlocklightle</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Custom_ThemeSherlockLight</item>
</style>
<style name="ActionBar.Solid.Custom_ThemeSherlockLight" parent="#style/Widget.Sherlock.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_exampthemesherlocklightle</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_exampthemesherlocklightle</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_exampthemesherlocklightle</item>
<item name="progressBarStyle">#style/ProgressBar.Custom_ThemeSherlockLight</item>
</style>
<style name="ActionBar.Transparent.Custom_ThemeSherlockLight" parent="#style/Widget.Sherlock.Light.ActionBar">
<item name="background">#drawable/ab_transparent_exampthemesherlocklightle</item>
<item name="progressBarStyle">#style/ProgressBar.Custom_ThemeSherlockLight</item>
</style>
<style name="PopupMenu.Custom_ThemeSherlockLight" parent="#style/Widget.Sherlock.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_exampthemesherlocklightle</item>
</style>
<style name="DropDownListView.Custom_ThemeSherlockLight" parent="#style/Widget.Sherlock.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_exampthemesherlocklightle</item>
</style>
<style name="ActionBarTabStyle.Custom_ThemeSherlockLight" parent="#style/Widget.Sherlock.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_exampthemesherlocklightle</item>
</style>
<style name="DropDownNav.Custom_ThemeSherlockLight" parent="#style/Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_exampthemesherlocklightle</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_exampthemesherlocklightle</item>
<item name="android:dropDownSelector">#drawable/selectable_background_exampthemesherlocklightle</item>
</style>
<style name="ProgressBar.Custom_ThemeSherlockLight" parent="#style/Widget.Sherlock.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_exampthemesherlocklightle</item>
</style>
<style name="ActionButton.CloseMode.Custom_ThemeSherlockLight" parent="#style/Widget.Sherlock.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_exampthemesherlocklightle</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Custom_ThemeSherlockLight.Widget" parent="#style/Theme.Sherlock">
<item name="popupMenuStyle">#style/PopupMenu.Custom_ThemeSherlockLight</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Custom_ThemeSherlockLight</item>
</style>
<style name="Theme.Sherlock.Translucent" parent="#style/Theme.Sherlock">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
<style name="Theme.Translucent" parent="#android:style/Theme.Translucent">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
</resources>
AndroidManifest.xml ::
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Custom_ThemeSherlockLight" >
<activity
android:name="com.example.testproject.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>
MainActivity.java
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ProgressDialog pDialog=new ProgressDialog(this);
pDialog =ProgressDialog.show(this,null, "Please Wait..", true);
pDialog.setContentView(R.layout.progress);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
progress.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="130dp"
android:layout_height="80dp"
android:background="#android:color/transparent"
android:gravity="center"
android:orientation="vertical" >
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:gravity="center"
android:text="Please wait.."
android:textColor="#color/black" />
</LinearLayout>
Please change the following lines of code in
progress.xml file
android:layout_width="130dp"
android:layout_height="80dp"
to
android:layout_width="match_parent"
android:layout_height="match_parent"
It should display in the center of the screen now.
Hope this helps!
Edit: Please change the layout_width attribute of TextView to "wrap_content".
I don't know if it helps or not. But to fix the cropping issue of "Please wait" text. Change the layout_width to "wrap_content" like this
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:gravity="center"
android:text="Please wait.."
android:textColor="#color/black" />
I am trying to implement custom app title. I made a custom layout to change the title text color to white.
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="0dp"
android:text="#string/title_activity_main"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/textColorWhite"/>
And in the activity onCreate()
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.activity_home);
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.my_icon);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.layout_custom_app_title);
It fails to work on Android 2.2 device. However, I tested successfully on version 4.0
Does anyone got any workaround?
EDIT:
<style name="customWindowTitle">
<item name="android:textColor">#color/textColorWhite</item>
</style>
<style name="LightThemeSelector" parent="android:Theme.Light">
<item name="android:windowBackground">#drawable/app_background</item>
<item name="android:textColor">#color/textColorBlack</item>
<item name="android:windowTitleStyle">#style/customWindowTitle</item>
</style>
you can do this easily by using custom theme. To do so here is the procedure
in style.xml add
<resources>
<style name="CustomWindowTitleBackground">
<item name="android:background">#color/textColorWhite</item>
// here you can add other attributes
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">25dip</item>
<item name="android:windowTitleBackgroundStyle">#style/CustomWindowTitleBackground</item>
</style>
</resources>
and in AndroidManifest.xml add
<application android:icon="#drawable/icon" android:label="#string/app_name" android:theme="#style/CustomTheme">
I have a styles.xml where I have defined styles
<!-- =============================================================== -->
<!-- Dark styles -->
<!-- =============================================================== -->
<style name = "AppBgDark">
<item name="android:background">#333333</item>
</style>
<style name = "CardBgDark">
<item name="android:background">#drawable/rounded_corners_dark</item>
</style>
<style name="event_title_dark">
<item name="android:textColor">#fff</item>
</style>
<style name="event_date_dark">
<item name="android:textColor">#fff</item>
</style>
<style name="event_location_dark">
<item name="android:textColor">#aaa</item>
</style>
<style name="event_calendar_dark">
<item name="android:textColor">#aaa</item>
</style>
<style name="Actionbar_dark" parent= "Widget.Sherlock.Light.ActionBar">
<item name = "android:background">#333333</item>
the same way for a light theme as well.
Then i have created a themes.xml and a attrs.xml to refference these styles.
The problem is when i apply the references from the attrs.xml in the layout i can see no changes happening
For example:
<LinearLayout
android:id="#+id/cardlayout"
style="?card_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:orientation="vertical"
android:padding="7dp" >
where am I going wrong? Any suggestions? I am really confused!!!