To change the Text color for TextView when it is Pressed or brought on Focus you need to create a selector XML file under res folder. If you do not find a color folder just create a new folder named "color"
Now Right Click on the color folder and select Android XML file
Now select Selector as Root element
res->color->textview_selector.xml<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="#878782"/>
<item android:state_focused="true" android:color="#483728"/>
<item android:color="#ff000000"/>
</selector>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:textColor="@color/textview_selector"
android:ems="10" >
<requestFocus />
</EditText>
</RelativeLayout>
More Posts related to Android,
- Change Android Toast background color
- Maven : java.lang.ClassNotFoundException: Xmx512m
- This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView) Lint Error
- Android Alert Dialog with Checkboxes example
- Android Error Generating Final Archive - Debug Certificate Expired
- How to add Newline to text in Android TextView
- Read Text file from SD Card : Android Programming
- [FIX] AndroidRuntime: FATAL EXCEPTION: main - java.lang.RuntimeException NullPointerException
- ActivityManager Warning: Activity not started, its current task has been brought to the front
- INSTALL_FAILED_INSUFFICIENT_STORAGE Android Error
- Android Developers Bluetooth Tutorial
- java.lang.ClassNotFoundException android.support.v7.widget.Toolbar [Fix]
- Android: Save Data in local Db using Android Room
- Channel 50 SMSes received every few minutes Android Phones
- 21 Useful Android Emulator Short-cut Keyboard Keys
- Changing Android Intent Tittle using java code
- Android : No Launcher activity found! Error
- How to change TextView or EditText Text Color on Focus and on Press
- How to display Toast on Button Click : Android
- Android : Execute some code after back button is pressed
- Stop android adb service from command prompt or terminal
- [Soluiton] You already have the latest version of Android Studio installed
- Create Custom Android AlertDialog
- Android R Cannot Be Resolved To A Variable
- How to make Android EditText not editable
More Posts:
- Indent Python code in Notepad++ - Python
- Find Java JRE Installation location Mac OS X - Mac-OS-X
- Android : java.lang.IllegalArgumentException File contains a path separator - Android
- Read and Parse XML file using Java DOM Parser [Java Tutorial] - Java
- How to fix java.net.NoRouteToHostException in Android Studio - Android-Studio
- pip get list of all outdated Python packages - Python
- iOS Fix: This app is no longer shared with you. To use it, you must buy it from the App Store. - Apple
- [Gmail] Calling in Hangouts will be turned off soon. - News