how to add online created android theme in my project - android

I am new to android application development.I used http://android-holo-colors.com/
to create theme for my application.
It created a theme named ei_theme.
I got the drawable folders,layout,and values folder.
The values folder consist of colors_ei_theme,dimens_ei_theme,styles_ei_theme,themes_ei_theme.
Now i am confused what to add in the manifest file to use the theme.
I guess u cant add more than one theme to in application tag in the manifest.
Can u please tell me how to use these.
here are the contents of styles_ei_theme
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with http://android-holo-colors.com -->
-<resources xmlns:android="http://schemas.android.com/apk/res/android">
-<style parent="android:Widget.Holo.AutoCompleteTextView" name="AutoCompleteTextViewEi_Theme">
<item name="android:dropDownSelector">#drawable/ei_theme_list_selector_holo_dark</item>
<item name="android:background">#drawable/ei_theme_edit_text_holo_dark</item>
</style>
-<style parent="android:Widget.Holo.Button" name="ButtonEi_Theme">
<item name="android:background">#drawable/ei_theme_btn_default_holo_dark</item>
</style>
-<style parent="android:Widget.Holo.ImageButton" name="ImageButtonEi_Theme">
<item name="android:background">#drawable/ei_theme_btn_default_holo_dark</item>
</style>
-<style name="TabEi_Theme">
<item name="android:gravity">center_horizontal</item>
<item name="android:paddingLeft">16dip</item>
<item name="android:paddingRight">16dip</item>
<item name="android:background">#drawable/ei_theme_tab_indicator_holo</item>
<item name="android:layout_width">0dip</item>
<item name="android:layout_weight">1</item>
<item name="android:minWidth">80dip</item>
</style>
-<style name="TabTextEi_Theme">
<item name="android:textColor">#ffffff</item>
<item name="android:textSize">12sp</item>
<item name="android:textStyle">bold</item>
<!-- v14 <item name="android:textAllCaps">true</item> -->
<item name="android:ellipsize">marquee</item>
<item name="android:maxLines">2</item>
<item name="android:maxWidth">180dip</item>
</style>
</resources>
here are contents of themes_ei_theme
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with http://android-holo-colors.com -->
-<resources xmlns:android="http://schemas.android.com/apk/res/android">
-<style parent="android:Theme.Holo" name="Ei_Theme">
<item name="android:editTextBackground">#drawable/ei_theme_edit_text_holo_dark</item>
<item name="android:textColorHighlight">#9933b5e5</item>
<item name="android:textSelectHandleLeft">#drawable/ei_theme_text_select_handle_left</item>
<item name="android:textSelectHandleRight">#drawable/ei_theme_text_select_handle_right</item>
<item name="android:textSelectHandle">#drawable/ei_theme_text_select_handle_middle</item>
<item name="android:autoCompleteTextViewStyle">#style/AutoCompleteTextViewEi_Theme</item>
<item name="android:listChoiceIndicatorMultiple">#drawable/ei_theme_btn_check_holo_dark</item>
<item name="android:listChoiceIndicatorSingle">#drawable/ei_theme_btn_radio_holo_dark</item>
<item name="android:buttonStyle">#style/ButtonEi_Theme</item>
<item name="android:imageButtonStyle">#style/ImageButtonEi_Theme</item>
</style>
</resources>

There are two ways to apply theme to your activity through AndroidManifest.xml file.
1- Apply theme in the application tag. This applies this theme to all activities in the application like:
<application
android:theme = "#style/Ei_Theme" >
...
</application>
2- Apply theme to each activity individually in AndroidManifest.xml under application tag. This applies this theme to only this activity:
<application >
<activity
android:theme = "#style/Ei_Theme" >
...
</activity>
</application>

Related

Default theme crashing application

How to use device default theme? If I use this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="#android:style/Theme.DeviceDefault">
</style>
</resources>
it is crashing application. Exception
I don't know if the theming is the issue but to apply themes you will do the following..
add/change in styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat">
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryDark">#color/primaryColorDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="StyledDialog.Base" parent="Theme.AppCompat.Dialog">
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryDark">#color/primaryColorDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
create a folder in res called values-v21 and copy the styles.xml into now change there the code to something like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="AppTheme.Base">
<item name="android:colorPrimary">#color/primaryColor</item>
<item name="android:colorPrimaryDark">#color/primaryColorDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
</style>
<style name="StyledDialog" parent="Theme.AppCompat.Dialog">
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryDark">#color/primaryColorDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
In your manifest you will have to call the theme by
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
Now your app will support the default theming of Lollipop and earlier versions of android.
Edit: Don't get confused by the "Dialog"-entries.. I just overwrite them to apply the theming to them with an other style..

Error: No resource found that matches the given name: attr 'hlv_listViewStyle'

I have to use Horizontal list-view library in my android code when I am creating a demo app of Horizontal list-view Library it is throwing error.
No resource found that matches the given name: attr 'hlv_listViewStyle'.
Platform:4.4.2
API Level:19
AndroidManifest.xml:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
res\values\styles.xml:
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="hlv_listViewStyle">#style/HListView</item>
<item name="hlv_absHListViewStyle">#style/AbsHListView</item>
<item name="hlv_listPreferredItemWidth">64dip</item>
</style>
<style name="AbsHListView">
<item name="android:scrollbars">horizontal</item>
<item name="android:fadingEdge">horizontal</item>
</style>
<style name="HListView" parent="AbsHListView">
<item name="android:listSelector">#android:drawable/list_selector_background</item>
<item name="android:cacheColorHint">?android:attr/colorBackgroundCacheHint</item>
<item name="android:divider">#android:drawable/divider_horizontal_bright</item>
<item name="android:scrollingCache">false</item>
<item name="android:overScrollMode">always</item>
<item name="android:fastScrollEnabled">true</item>
<item name="android:smoothScrollbar">false</item>
<item name="android:choiceMode">multipleChoiceModal</item>
<item name="hlv_stackFromRight">false</item>
<item name="hlv_measureWithChild">0</item>
<item name="hlv_dividerWidth">3dip</item>
<item name="hlv_headerDividersEnabled">true</item>
<item name="hlv_footerDividersEnabled">true</item>
<item name="hlv_transcriptMode">disabled</item>
</style>
I am an android newbie.Thanks very much!
It could be that you are missing the attribute hlv_listViewStyle. The style is there, but the reference linking it with the theme might not be. Check in your attr.xml file (if it exists, else create it under values folder) that you have the following:
<resources>
<attr name="hlv_listViewStyle" format="reference" />
</resources>
I also was facing the same issue and adding the following like to my build.gradle fixed it:
compile project(':library')
// where "library" was the name of my HorizontalVariableListView library
Also make sure that your styles.xml looks like that of the demo:
<style name="AppTheme" parent="AppBaseTheme">
<item name="hlv_listViewStyle">#style/HListView</item>
<item name="hlv_absHListViewStyle">#style/AbsHListView</item>
<item name="hlv_listPreferredItemWidth">64dip</item>
</style>
<style name="AbsHListView">
<item name="android:scrollbars">horizontal</item>
<item name="android:fadingEdge">horizontal</item>
</style>
<style name="HListView" parent="AbsHListView">
<item name="android:listSelector">#android:drawable/list_selector_background</item>
<item name="android:cacheColorHint">?android:attr/colorBackgroundCacheHint</item>
<item name="android:divider">#android:drawable/divider_horizontal_bright</item>
<item name="android:scrollingCache">false</item>
<item name="android:overScrollMode">always</item>
<item name="android:fastScrollEnabled">true</item>
<item name="android:smoothScrollbar">false</item>
<item name="android:choiceMode">multipleChoiceModal</item>
<item name="hlv_stackFromRight">false</item>
<item name="hlv_measureWithChild">0</item>
<item name="hlv_dividerWidth">3dip</item>
<item name="hlv_headerDividersEnabled">true</item>
<item name="hlv_footerDividersEnabled">true</item>
<item name="hlv_transcriptMode">disabled</item>
</style>

Text Select Handle doesn't seem to change

I have this theme in values/styles.xml, that I apply to my whole application.
<!-- Base application theme. -->
<style name="AppTheme" parent="#style/_AppTheme">
<!-- a bunch of things... -->
<item name="android:textColorHighlight">#9999cc00</item>
<!-- a bunch of things... -->
</style>
<style name="_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"/>
Then in values-v9
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="#style/_AppTheme">
<item name="android:textSelectHandleLeft">#drawable/apptheme_text_select_handle_left</item>
<item name="android:textSelectHandleRight">#drawable/apptheme_text_select_handle_right</item>
<item name="android:textSelectHandle">#drawable/apptheme_text_select_handle_middle</item>
</style>
</resources>
And finally in values-v11
<?xml version="1.0" encoding="utf-8"?>
<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="#style/_AppTheme">
<item name="android:dropDownSpinnerStyle">#style/SpinnerAppTheme</item>
<item name="android:listChoiceBackgroundIndicator">#drawable/apptheme_list_selector_holo_light</item>
<item name="android:activatedBackgroundIndicator">#drawable/apptheme_activated_background_holo_light</item>
<item name="android:textColorHighlight">#9999cc00</item>
<item name="android:textSelectHandleLeft">#drawable/apptheme_text_select_handle_left</item>
<item name="android:textSelectHandleRight">#drawable/apptheme_text_select_handle_right</item>
<item name="android:textSelectHandle">#drawable/apptheme_text_select_handle_middle</item>
</style>
</resources>
All of the drawables are in their respective folder.
This has no effect in changing the text select handle in any part of the application.
Is this because of the AppCompat library use maybe?
How do I repair?
Using this link
http://android-holo-colors.com/
The worst part here was to find the "name" for this item and how it is called inside the theme. So I looked through every drawable in the android SDK folder and finally found the drawables named "text_select_handle_middle", "text_select_handle_left" and "text_select_handle_right".
So the solution is simple: Add these drawables with customized design/color to your drawable folder and add them to your theme style definition like:
<style name="MyCustomTheme" parent="#style/MyNotSoCustomTheme">
<item name="android:textSelectHandle">#drawable/text_select_handle_middle</item>
<item name="android:textSelectHandleLeft">#drawable/text_select_handle_left</item>
<item name="android:textSelectHandleRight">#drawable/text_select_handle_right</item>
</style>

AppCompat Title color

I'm having some troubles changing the color for the ActionBar. I'm using AppCompat library for support. Everything else works: like background, or selector ... but the title color isn't changing.
This is my style file:
<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.Customtitletheme" parent="#style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">#drawable/selectable_background_customtitletheme</item>
<item name="android:actionBarItemBackground" tools:targetApi="14">#drawable/selectable_background_customtitletheme</item>
<item name="popupMenuStyle">#style/PopupMenu.Customtitletheme</item>
<item name="android:popupMenuStyle" tools:targetApi="11">#style/PopupMenu.Customtitletheme</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Customtitletheme</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Customtitletheme</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Customtitletheme</item>
<item name="android:actionBarTabStyle" tools:targetApi="11">#style/ActionBarTabStyle.Customtitletheme</item>
<item name="actionDropDownStyle">#style/DropDownNav.Customtitletheme</item>
<item name="android:actionDropDownStyle" tools:targetApi="11">#style/DropDownNav.Customtitletheme</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Customtitletheme</item>
<item name="android:actionBarStyle" tools:targetApi="11">#style/ActionBar.Solid.Customtitletheme</item>
<item name="actionModeBackground">#drawable/cab_background_top_customtitletheme</item>
<item name="android:actionModeBackground" tools:targetApi="11">#drawable/cab_background_top_customtitletheme</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_customtitletheme</item>
<item name="android:actionModeSplitBackground" tools:targetApi="14">#drawable/cab_background_bottom_customtitletheme</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Customtitletheme</item>
<item name="android:actionModeCloseButtonStyle" tools:targetApi="11">#style/ActionButton.CloseMode.Customtitletheme</item>
<item name="actionMenuTextColor">#color/actionbar_text</item>
<item name="android:actionMenuTextColor" tools:targetApi="11">#color/actionbar_text</item>
</style>
<style name="ActionBar.Solid.Customtitletheme" parent="#style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#drawable/ab_solid_customtitletheme</item>
<item name="android:background">#drawable/ab_background_textured_customtitletheme</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_customtitletheme</item>
<item name="android:backgroundStacked" tools:targetApi="14">#drawable/ab_stacked_solid_customtitletheme</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_customtitletheme</item>
<item name="android:backgroundSplit" tools:targetApi="14">#drawable/ab_background_textured_customtitletheme</item>
<item name="progressBarStyle">#style/ProgressBar.Customtitletheme</item>
<item name="android:progressBarStyle">#style/ProgressBar.Customtitletheme</item>
<item name="titleTextStyle">#style/ActionBar.CustomTitle</item>
<item name="android:textStyle">#style/ActionBar.CustomTitle</item>
</style>
<style name="PopupMenu.Customtitletheme" parent="#style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">#drawable/menu_dropdown_panel_customtitletheme</item>
</style>
<style name="DropDownListView.Customtitletheme" parent="#style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">#drawable/selectable_background_customtitletheme</item>
</style>
<style name="ActionBarTabStyle.Customtitletheme" parent="#style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">#drawable/tab_indicator_ab_customtitletheme</item>
</style>
<style name="DropDownNav.Customtitletheme" parent="#style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">#drawable/spinner_background_ab_customtitletheme</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_customtitletheme</item>
<item name="android:dropDownSelector">#drawable/selectable_background_customtitletheme</item>
</style>
<style name="ProgressBar.Customtitletheme" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/progress_horizontal_customtitletheme</item>
</style>
<style name="ActionButton.CloseMode.Customtitletheme" parent="#style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">#drawable/btn_cab_done_customtitletheme</item>
</style>
<!-- ActionBar title text -->
<style name="ActionBar.CustomTitle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Customtitletheme.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Customtitletheme</item>
<item name="android:popupMenuStyle" tools:targetApi="11">#style/PopupMenu.Customtitletheme</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Customtitletheme</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Customtitletheme</item>
</style>
</resources>
I have also used different values folders, like values-v14 or values-v11, but the same result.
If I change the parent from "Theme.AppCompat.Light" to "Theme.AppCompat.Dark" the color changes, but when I want to use some custom color it is not working...
Also, this is how I used the specified theme in manifest:
<activity
android:name="com.cos.ShareActivity"
android:label="Share File"
android:parentActivityName="com.cos.FileManagerActivity"
android:theme="#style/Theme.Customtitletheme" >
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.cos.FileManagerActivity" />
</activity>
What I am doing wrong that the color item is ignored ?
After so much time lost trying to figure it out, I found that it was a typo ... damn ... I have used android:textStyle instead of android:titleTextStyle. When I typed in that line the IDE auto-suggest typed the first one :(

Create custom titlebar in Android

I created a custom title bar for my application but I am having some problems implementing it. I want to change the color and the appearance for the text and title bar
The layout of the styles.xml is as below:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme">
<item name="android:tabWidgetStyle">#style/LightTabWidget</item>
</style>
<style name="MyWindowTitleBackground" parent="#android:style/WindowTitleBackground">
<item name="android:background">#android:drawable/title_bar</item>
</style>
<style name="MyWindowTitle" parent="#android:style/WindowTitle">
<item name="android:singleLine">true</item>
<item name="android:windowTitleSize">40dip</item>
<item name="android:textAppearance">#style/MyTextAppearance</item>
<item name="android:shadowColor">#BB000000</item>
<item name="android:shadowRadius">2.75</item>
</style>
<style name="MyTextAppearance" parent="#android:style/TextAppearance.WindowTitle">
<item name="android:textColor">#3A6629</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">bold</item>
</style>
<style name="LightTabWidget" parent="#android:style/Widget.TabWidget">
<item name="android:textSize">20px</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#FF5721</item>
</style>
</resources>
And I have added that theme in the manifest file as follows:
<application android:icon="#drawable/icon" android:label="#string/app_name" android:theme="#android:style/Theme.Light">
<activity android:name="LAFoodBankAboutUs" android:label="#string/app_name" android:theme="#style/MyTheme">
What do I have to do to show the custom title bar?
By now (after some years), the Toolbar is available. It features a lot of customization possibilities and is also available via the Support Library

Categories

Resources