android: How to change ListPreference title colour? - android

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.

Related

How to change color of the scroll limit in android studio

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

When trying to use the material theme on Android, my title bar is not using the primary colour

From my research, it appears that when using the material theme on Android the title bar should take on the primary color but for me, it stays black. I know the theme itself is working as things did change to black when I first applied the default(dark) theme. I have this set in the styles.xml file:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>
</resources>
The colors referenced from colors.xml are working as they show up on the s the de in android studio.
I have tried looking for a way to manually change the title bar but I have only found ways to do it programatically and not through layout files. I have attached a pic of what the title bar currently looks like and what i would like it to look like below:
Current title bar
What I want it to look like
Change it to
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>

How to change textview default color (Theme.AppCompat.Light.DarkActionBar)

I am trying to understand the theming and styling system of Android and basically attempt to do the simplest thing - change the default color of TextView texts.
According to the source code of TextView the default style would be:
<item name="textViewStyle">#style/Widget.TextView</item>
Looking at this style I discover the following:
<style name="Widget.TextView">
<item name="textAppearance">?attr/textAppearanceSmall</item>
....
</style>
It seems that the default textAppearance is set to textAppearanceSmall (from the theme).
I look into themes.xml for the referenced textAppearanceSmall and find this:
<item name="textAppearanceSmall">#style/TextAppearance.Small</item>
Aha - it references this TextAppearance.Small:
<style name="TextAppearance.Small">
<item name="textSize">14sp</item>
<item name="textColor">?textColorSecondary</item>
</style>
Ok, we are getting somewhere - maybe? By default TextView uses the color "textColorSecondary".
First immediate question: Why is it references so weirdly? (questionmark but not like '?attr/textColorSecondary')?
I go back to the themes.xml file and discover this:
<item name="textColorSecondary">#color/secondary_text_dark</item>
At this point I am pretty sure that I have to override textColorSecondary in my custom AppTheme like so:
<!-- Base application theme. -->
<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="android:textColorPrimary">#00CC00</item>
</style>
This does of course not work... the question is - why?
BTW: All the files I am looking at (theme.xml & styles.xml) reside in my Android SDK directory:
C:\AndroidSDK\platforms\android-26\data\res\values
Try this:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:textColor">#color/white</item>
</style>

How to change color of ActionBar title using AppCompat.Light

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.

How to change highlighted EditText color in Android?

I am totally new to Android and ran into the following: while using the Material Light Theme my EditText turns a shade of pink upon selection.
I searched around how to change it and found the following telling me to change the android:textColorHighlight to my preferred color:
How to set color of selection in EditText in my custom theme? (android)
Sadly this doesn't seem to work for me.
This is my styles.xml:
<!-- res/values/styles.xml -->
<resources>
<!- theme inherits from the material theme -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:colorPrimary">#color/colorPrimary</item>
<item name="android:colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/lightText</item>
<item name="android:navigationBarColor">#color/navigationBarColor</item>
<item name="android:textColorHighlight">#color/textColorHighlight</item>
<!-- theme customizations -->
</style>
</resources>
Any pointers as to what I'm doing wrong?
Thanks!
Found it:
EditText uses the themecolor defined as: android:colorAccent
So:
<item name="android:colorAccent">#color/colorAccent</item>
Hope this helps anyone in the future
Go to the settings:
And here's the result:

Categories

Resources