The textColor attribute isn't working. Here's my XML:
<PreferenceCategory android:title="Title" android:textColor="#00FF00">
Any ideas?
Go to res>values>styles. xml> and add this code to your <style > </style> the style should must be app base theme in this @color/activ is color resources added to colors. Show activity on this post. I am using the PreferenceFragmentCompat, the below solution worked for me.
What is the Preferences Framework? Android system provides many ways to save data for your application. One of them is Preferences Framework , through Android preference framework we can easily develop screen that allows user to modify preferences.
use this customize PreferenceCategory class :
public class MyPreferenceCategory extends PreferenceCategory { public MyPreferenceCategory(Context context) { super(context); } public MyPreferenceCategory(Context context, AttributeSet attrs) { super(context, attrs); } public MyPreferenceCategory(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onBindView(View view) { super.onBindView(view); TextView titleView = (TextView) view.findViewById(android.R.id.title); titleView.setTextColor(Color.RED); } }
and add this at your Pref.xml file :
<ali.UI.Customize.MyPreferenceCategory android:title="@string/pref_server" />
One solution is to make a theme for your PreferenceScreen. So in your themes.xml or styles.xml (better to put it in themes.xml) :
<style name="PreferenceScreen" parent="YourApplicationThemeOrNone"> <item name="android:textColor">@color/yourCategoryTitleColor</item> </style>
then in your AndroidManifest.xml :
<activity android:name="MyPreferenceActivity" ... android:theme="@style/PreferenceScreen" > </activity>
It worked perfectly for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With