आप android:switchTextAppearance
विशेषता, जैसे का उपयोग करना चाहिए:
android:switchTextAppearance="@style/SwitchTextAppearance"
और शैलियों में:
<style name="SwitchTextAppearance" parent="@android:style/TextAppearance.Holo.Small">
<item name="android:textColor">@color/my_switch_color</item>
</style>
आप भी यह कोड में, यह भी शैलियों ऊपर का उपयोग कर सकते हैं:
mySwitch.setSwitchTextAppearance(getActivity(), R.style.SwitchTextAppearance);
... औरके लिए -और Switch
अगर आपके SwitchTextAppearance
शैली एक textColor
आप setSwitchTextAppearance
में Switch
स्रोत कोड में जाँच कर सकते हैं प्रदान नहीं करता है इस रंग का उपयोग किया जाएगा:
ColorStateList colors;
int ts;
colors = appearance.getColorStateList(com.android.internal.R.styleable.
TextAppearance_textColor);
if (colors != null) {
mTextColors = colors;
} else {
// If no color set in TextAppearance, default to the view's textColor
mTextColors = getTextColors();
}
ts = appearance.getDimensionPixelSize(com.android.internal.R.styleable.
TextAppearance_textSize, 0);
if (ts != 0) {
if (ts != mTextPaint.getTextSize()) {
mTextPaint.setTextSize(ts);
requestLayout();
}
}
पोस्ट अपने कोड .. –
वहाँ कोई विशेष कोड है , यह सिर्फ लेआउट में एक स्विच है, जो आईडी द्वारा पाया जाता है। और कोड में मैंने switch.setTextColor (Color.WHITE) सेट किया है; –