In my AndroidManifest file i do not declare a theme.
The result is:
black background and ABS with blue background, also states of list item's is blue.
thats fine.
now i want to make to set the indeterminateProgressStyle to Widget.ProgressBar.Small
Therefore i have to declare my own style like this:
<style name="Custom" parent="??">
<item name="android:actionBarStyle">#style/ActionBarIPS</item>
</style>
what should i enter in the parent parameter?
i want all style behaviors like before (black background with blue ABS and blue list item states etc as it is defined when i dont declare a theme attribute in AndroidManifest.
EDIT:
i also need to know this parent's value:
<style name="ActionBarIPS" parent="ABS with blue background">
<item name="android:indeterminateProgressStyle">#style/IndeterminateProgress</item>
</style>
the version without a style in manifest:
the version with custom style and parent=Theme.Sherlock
i want the first version with indeterminate spinner set to "small"
It's depend to your current style, It can be Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.ForceOverflow and etc, e.g:
<style name="Custom" parent="Theme.Sherlock or Theme.Sherlock.Light">
<item name="android:actionBarStyle">#style/ActionBarIPS</item>
<item name="android:indeterminateProgressStyle">#style/IndeterminateProgress</item>
</style>
Note: You must declare this style in style.xml in your values directory.
Edited:
You got blue ActionBar without using ABS because you're using Samsung TouchWiz default UI.
If you install your APK in non-samsung devices you won't see this blue action bar, But If you are forced to have blue actionbar then put the following image in your drawable directory and set it as your actionbar background through:
getSupportActionBar().setBackgroundDrawable(getResources()
.getDrawable(R.drawable.TouchWiz_ActionBar_Bg));
Try to use "Theme.Sherlock" as a parent. Also I suggest to add:
<item name="actionBarStyle">#style/ActionBarIPS</item>
Related
Background
I'm trying to prepare dark theme for an app, and one of the requirements is to have a specific color for cards and dialogs : #ff3c454c
The problem
Whether I set it by force ( app:cardBackgroundColor="#3c454c") , by reference ( app:cardBackgroundColor="#color/...) or just in the theme - in all cases I don't get the color I've set. Instead I get the color of #525A61.
I've tested just a red color (#f00) just to be sure it affects the card, and it does, and for this color it indeed gets to be fine. But for the color I've set, it doesn't.
What I've tried
As I wrote, I tried multiple ways to set the color. In the beginning I wanted to use just the theme itself, so I've set it as such:
styles.xml
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
...
<item name="colorBackgroundFloating">#color/colorBackgroundFloating</item>
<item name="colorSurface">#color/colorBackgroundFloating</item>
</style>
res/values-night/colors.xml
<color name="colorBackgroundFloating">#ff3c454c</color>
Later I tried to use the color directly and even set it as hard coded. Still got the incorrect color when it gets shown.
Seeing this could be a bug on the library itself, I've reported about this here (include a sample project, if you wish to check it out).
I've noticed the exact same issue occurs for BottomNavigationView and probably other similar cases.
The question
Why does it occur?
Is there any workaround for this?
Something that will fix it globally for all views that use these attributes ?
What you are seeing is the elevation overlay that they introduced to make elevation more noticeable while in Dark Theme, where shadows are not so visible. You can read about it here : https://material.io/develop/android/theming/dark/ in the section "Elevation Overlays"
The simple solution if you don't want this behavior is to add this to your theme.
<item name="elevationOverlayEnabled">false</item>
And you can also adjust it to another color or even a more subtle version of the overlay by changing the alpha:
<item name="elevationOverlayColor">#80FFFFFF</item>
EDIT with more info from https://github.com/material-components/material-components-android/issues/1133
If you want to disable it for only one component or widget, you can define a style for it with a theme overlay and use it in a specific layout:
<style name="ThemeOverlay.MyApp.ElevationOverlayDisabled" parent="">
<item name="elevationOverlayEnabled">false</item>
</style>
<style name="Widget.MyApp.CardView" parent="Widget.MaterialComponents.CardView">
<item name="materialThemeOverlay">#style/ThemeOverlay.MyApp.ElevationOverlayDisabled</item>
</style>
And if you want to disable it for all cards in your app but keep it in other components you can set that style as the default style for material card views:
# Set in your app theme
<item name="materialCardViewStyle">#style/Widget.MyApp.CardView</item>
I'd like to override the accentColor used by v14 PreferenceFragmentCompat.
I'm using a pink accent color for the outer frame of my Android app. This creates problems in many situations as it causes standard controls to use an accent color that's close enough to red that the effect is disturbing. Be that as it may, I like the effect of having a pink FAB and button controls on the frame.
For child activities, I use a them with the standard teal accent color. However, I have a PreferenceFragment compat in a drawer on the main activity, and I cannot figure out how to override the main activity's accent color.
Things I have tried (none of which work):
Setting a theme on the frame of the fragment that receives the PreferenceFragmentCompat (doesn't work):
<FrameLayout android:id="#+id/preferenceFragmentFrame"
android:layout_width="match_parent" android:layout_height="0dp"
android:layout_weight="1"
android:theme="#style/AppTheme.TealAccentColor"
/>
where the AppTheme.TealAccentColor style provides an explicit teal acccentColor.
Setting the accentColor in a preference theme (doesn't work):
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="preferenceTheme">#style/MyPreferenceThemeOverlay</item>
</style>
<style name=MyPreferenceThemeOverlay parent="PreferenceThemeOverlay.v14.Material>
<item name="colorAccent">#color/colorAccentTeal</item>
</style>
Adding an accent color to preference-v14's PreferenceThemeOverlay (doens't work):
<!-- use the library's theme-->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="preferenceTheme">PreferenceThemeOverlay.v14.Material</item>
</style>
<!-- but add an accentColor item to the library's theme -->
<style name="PreferenceThemeOverlay.v14">
<item name="colorAccent">#color/colorAccentTeal</item>
</style>
No matter what I do, PreferenceFragmentCompat seems to take the pink accent color from the Activity's theme instead.
I'm sure it has something to do with a disconnect between the Activity's theme and a Fragment's theme. But there's no xml element for the fragment, since PreferenceFragmentCompat provides its own layout.
Maybe there's a way to do it programmatically with an override in the class that extends PreferenceFragmentCompat, but if there is, I can't imagine what it would be. Most of the attack points I can think of either have access to the internally-created layout, or have access to the layout after it has been created, which is too late.
A picture might help:
Have you tried overriding android:colorAccent instead of colorAccent?
Use the method you described as "Setting the accentColor in a preference theme", just change the attribute name.
The preference support library doesn't take into consideration appcompat at all, so
forget about appcompat attributes
color* attributes will only work on API 21, I think
If you want consistent behavior you can use my library Android Support Preference which aims to connect preference and appcompat support libraries.
Then you original style with colorAccent (unprefixed) will work as expected.
I have a Theme.Holo.Light style, which is custom designed. Therefore I want to have the little tick on the contextual action mode in normal Theme.Holo style.
As you can see, it would look much better if the tick was white.
I thought the following would work, but no success.
<style name="PlayerTheme" parent="#android:style/Theme.Holo.Light">
...
<item name="android:actionModeCloseButtonStyle">#android:style/Widget.ActionButton.CloseMode</item>
</style>
Is there some way to make the tick white? Thanks!
You can copy the standard white check mark from the android icon pack into your project as a drawable. The icon pack can be found here: https://developer.android.com/design/downloads/index.html. It's under the 01_core_accept folder and named ic_action_accept.png.
Then, set the following property in your style file:
<item name="android:actionModeCloseDrawable">#drawable/ic_action_accept</item>
That should solve your problem.
I have a custom theme created with this generator. It has a custom style for Spinners which I don't like. I want to change the background drawable but I can't seem to figure out which property controls this.
This is what the themed version looks like
And here is what it will look like when using the Holo.Light theme.
Notice the dark gray lines around the dropdown list in the first (themed) image. This is what I want to get rid of. What property controls this? I want them to match the default.
Also, what controls the vertical aligment of the dropdown list? As you can see, it is overlapping with the Spinner in the first image (the line under it isn't visible as it is in the second image).
The attribute you want is android:popupBackground on the Spinner element.
If you look closely, the holo popup also overlaps the spinner some, but there is a bunch of padding for the drop shadow, so it looks good.
However, you can use android:dropDownVerticalOffset on the Spinner element to adjust it.
We came across the same issue. It has to do with the Android Holo theme generator.
Here are the lines that you should remove from your Theme.xml file...
<item name="android:spinnerStyle">#style/SpinnerCustom</item>
<item name="android:spinnerDropDownItemStyle">#style/SpinnerDropDownItemCustom</item>
<item name="android:popupMenuStyle">#style/PopupMenu.Custom</item>
<item name="android:dropDownListViewStyle">#style/DropDownListView.Custom</item>
<item name="android:actionDropDownStyle">#style/DropDownNav.Custom</item>
...by removing these, we now have the standard Holo.Light theme on the spinner dropdowns.
You need to change the parent of spinnertheme to android:Widget.Holo.Light.Spinner
<style name="SpinnerTHEME" parent="android:Widget.Holo.Light.Spinner">
<style name="spinner_style" parent="android:Widget.Holo.Light.Spinner">
<item name="android:paddingLeft">#dimen/ten_dp</item>
<item name="android:paddingRight">#dimen/ten_dp</item>
</style>
Is there a way to format all TextViews, Buttons or whatever with a theme ?
Like in CSS when i want to format all a-tags
a{
/some css here/
}
I want to do that in android via xml when I'm applying a theme to my application.
Any ideas ?Thanks
http://bartinger.at/
Update 1.0:
I want to create a theme that formats the text in all TextViews green and in all EditTexts red. So that i just apply the theme and I never have to worry about the style attribute!
Update 1.1:
So I found some that piece of code and I think that's a good beginning
<item name="android:textViewStyle">#style/MyTextView</item>
<item name="android:buttonStyle">#style/MyButton</item>
I think thats the answer to my question. But I have another one. I want to write my own ActionBar and wanted to know how I can apply a default style or default attributes (again without adding the style attribute in the layout xml :P )
I have a class
public class ActionBar extends LinearLayout{ }
and I'm gonna use it like that in my application
<at.bartinger.uil.ActionBar>....</at.bartinger.uil.ActionBar>
The ActionBar should have some default attributes (like height and width) and then adding some custom style attributes which could change from app to app (like background)
yes you can you can apply a theme to the whole application and then all your textviews will have that style.
Inside the styles.xml file you have to define your CustomTheme
for example:
<style name="CustomTheme" parent="android:Theme.Light">
<item name="android:windowBackground">#color/custom_theme_color</item>
<item name="android:colorBackground">#color/custom_theme_color</item>
</style>
you add something like text
"android:textStyle="myStyle" and specify the details in Mystyle
You can apply a style read more here.
for the action abr you should look here http://developer.android.com/guide/topics/ui/actionbar.html
especially at the bottom it explains very well how to style the bar