I am studing Support Design liabrary.I cannot understand the use of enterAlwaysCollapsed.It seems it will influece on pull down,but I tried and find nothing changed.
So,what is the use of enterAlwaysCollapsed,could you show me with a demo?
Let me answer it myself.
First the activity theme is AppTheme.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
And then Don't set fitsSystemWindows in xml.
Last use scroll flag scroll|enterAlways|enterAlwaysCollapsed.
The final effect is below
Related
My main app theme parent is MaterialComponents theme. I changed the colors, but material components (MaterialButton, InputLayout, EditText) are not using my accent color (they are using some blue color, my declared Accent color is Teal)
What is the issue? How is the best way to deal with theming Material Components?
My main theme:
<style name="AppTheme" parent="Theme.MaterialComponents">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Edit:
Changing theme to Theme.MaterialComponents.Bridge is not solving that problem.
Maybe you should try to use colorSecondary instead of colorAccent:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Original AppCompat attributes. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorSecondary">#color/colorAccent</item>
</style>
This works for me
The issue in my case was a different styles.xml declared for the specific API. I made a mistake in it, and when testing, that other values-v21/styles.xml was applied before styles.xml.
So long story short, check if the mistake is not present in other variants. I declared that variant wrong.
For those, trying to use a theme that inherits from Theme.MaterialComponents.* please also keep in mind not to use a regular Button class but com.google.android.material.button.MaterialButton instead.
Instead of:
<Button
(...)
style="#style/Widget.MaterialComponents.Button" />
Make sure to use:
<com.google.android.material.button.MaterialButton
(...)
style="#style/Widget.MaterialComponents.Button" />
Been there. Nothing to be ashamed of. :)
Inherit your app theme from Theme.AppCompat like:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
</style>
Note that dark or light theme is upon you but you need to extend Theme.AppCompat.
Try changing your styles.xml like this :
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
If this works, let me know
Edit : Try following this link for setting up material components https://medium.com/#pedromassango/android-material-design-components-setup-google-i-o18-part-1-8894f315b5e
I don't know if this is the correct name to design this but I will add an image to show what I want to do.
As you can see, when you are in the scroll limit, something like a colored wave appears. How could I change that color?
You just need to customise the AppTheme as I did:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#android:color/white</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:colorEdgeEffect">#color/colorAccent</item>
</style>
Add your color to the attribute "colorEdgeEffect".
<item name="android:colorEdgeEffect">#color/colorAccent</item>
And your problem will be solved
NOTE: This will only work for API 21 and above
Beginner coder here.
I am using PreferenceFragmentCompat to make a preference fragment that I can use with getSupportFragmentManager().
https://plus.google.com/+AndroidDevelopers/posts/9kZ3SsXdT2T
I am following the directions there, except I'm not sure how to set the preferenceTheme. My app crashes when I click on the settings menu with this exception is thrown
IllegalStateException: Must specify preferenceTheme in theme.
Where do I set the theme?
In values/styles.xml you have to add:
<item name="preferenceTheme">#style/PreferenceThemeOverlay.v14.Material</item>
use this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="preferenceTheme">#style/PreferenceThemeOverlay</item>
</style>
I've seen an amoung of posts about it and nothing works in my project.
This is my styles.xml:
<!-- Base application theme. -->
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
This provides me a beautiful interface like this:
I've tried a lot of things like defining:
#style/MyActionBar
And later I can redifine here the color of the title but later the colors declares previously desapear and the title doesn't turn it white (the color that I want).
I've searched everywhere and I hope somewho with the answer of this stupid and repeatly question.
Thanks, and sorry for the english.
I would like to change the title and line color of my ListPreference from blue to pink, to match the line of my action bar.
Any ideas? Thanks in advance!
I've been looking through Android's themes.xml and styles.xml looking at things like dialogPreferenceStyle, but haven't figured it out yet.
Had the same problem today.
Old thread, but I found this: and it works perfectly.
Simply modify your styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<!-- Add this -->
<item name="android:dialogTheme">#style/DialogStyle</item>
<item name="android:alertDialogTheme">#style/DialogStyle</item>
</style>
<!-- Customize your color here -->
<style name="DialogStyle" parent="android:Theme.Material.Dialog">
<item name="android:colorAccent">#color/colorAccent</item>
</style>
Ended up creating a custom ListPreference widget, following this answer.
I hoped to be able to simply change the style without having to implement a custom widget, but I haven't figured that out yet.