How To Change Switch Imput Text Color In Xml?
My text in my switch defined in a xml file won't to change it's color stay black as the activity background. I tried with the textcolor option without any success. Any ideas? My x
Solution 1:
For a switch
, add this to your styles.xml
file:
<style name="x" parent="@android:style/TextAppearance.Small">
<item name="android:textColor">#33CCFF</item>
</style>
Two options:
add this to your layout
XML
file:android:switchTextAppearance="@style/x"
add this to your Activity class after you've created an instance of your
switch
:switchInstance.setSwitchTextAppearance(getActivity(), R.style.x);
Note: path to styles.xml
file: Project Folder > res > values > styles.xml
Solution 2:
When you create an instance
of your EditText
or TextView
in your Activity
code, you can set the TextColor
, or Background Color
for that matter, there.
Ex.
import android.graphics.Color; // add to top of your class
TextView x = (TextView)findViewById(R.id.y);
x.setTextColor(Color.parseColor("red")); // one way
x.setTextColor(Color.rgb(255, 0, 0)); // another way
x.setBackgroundColor(Color.parseColor("colorString"));
x.setBackgroundColor(Color.rgb(red int value, green int value, blue int value));
Post a Comment for "How To Change Switch Imput Text Color In Xml?"