Ответ 1
Вы должны использовать атрибут 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);
... а для setTextColor
и Switch
- этот цвет будет использоваться, если ваш стиль SwitchTextAppearance
не предоставляет textColor
вы можете проверить его в Switch
исходном коде в setSwitchTextAppearance
:
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 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();
}
}