android - how to change switch imput text color in xml? -
my text in switch
defined in xml file won't change it's color stay black activity background. tried textcolor option without success. ideas?
my xml file
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hôte : " android:textcolor="#ffffff"/> <edittext android:background="#40ffffff" android:id="@+id/hostname" android:layout_width="200px" android:layout_height="wrap_content" android:textcolor="#ffffff"/> </linearlayout> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="utiliser https : " android:textcolor="#ffffff"/> <switch android:id="@+id/switch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:texton="on" android:textoff="off" android:textcolor="#ffffff" android:onclick="ontoggleclicked"/> </linearlayout> </linearlayout>
for switch
, add styles.xml
file:
<style name="x" parent="@android:style/textappearance.small"> <item name="android:textcolor">#33ccff</item> </style>
two options:
add layout
xml
file:android:switchtextappearance="@style/x"
add activity class after you've created instance of
switch
:switchinstance.setswitchtextappearance(getactivity(), r.style.x);
note: path styles.xml
file: project folder > res > values > styles.xml
Comments
Post a Comment