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?

enter image description here

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:

  1. add layout xml file:

    android:switchtextappearance="@style/x" 
  2. 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

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -