With setTextColor() method we can set the color for Textview.
For this method we need to pass color vallu
Textview has property 'textColor' attribute which is set a color of our choice. We can provide the color as hexa value in one of the four formats: rgb, argb, rrggbb, or aarrggbb. The syntax to set textColor attribute for TextView using different color formats is ... android:textColor="#92B" /> ... android:textColor="#A92B" /> ... android:textColor="#9C27B0" /> ... android:textColor="#CC9C27B0" /> Example 1 – TextView Color Let us create an Android application with Kotlin support in Android Studio and change the text color of TextView in XML layout file. activity_main.xml
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linear_layout_id" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> android:id="@+id/text_view_id" android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:textSize="40dp" android:padding="50dp" android:textColor="#9C27B0" android:text="@string/hello" />
We have used a string resource, and the contents of strings.xml is
There is no need to change the MainActivity.kt file. The default code would do.
MainActivity. import androidx.appcompat.app.AppCompatActivity import android.os.Bundle class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } }
textView.setTextColor(Color.parseColor("#ffffff"));
textView.setTextColor(Color.rgb(200,0,0));
textView.setTextColot(
ContextCompat.getColor(context, R.color.your_color);)
Change Text Color of TextView via XML Layout File
What is Android?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
What are symmetric and asymmetric encryption in the way Android interacts with the server?
How to reduce APK package size?
Google play store rejected my app due to SMS permission I removed SMS permission from the manifes
How to get complete address from latitude and longitude?
How can i comment inside xml file in android studio?
What are the notifications available in android?
How To Set Text Color Programmatically Android TextView?
How to Generate signed apk with android studio
How do I generate random numbers in Dart?
What is Android Fragments?
What is the difference between match_parent and fill_parent?
Duplicate files during packaging of APK” build.gradle issue: Android Studio
Permission denied for window type 2010 in Marshmallow device
Is There A Way To Get The Source Code From An APK File? (or) How to decompile apk?
'constructor Handler()' is deprecated. Deprecated in Java, How to use Handler() class in And
How do i load image from drawable folder in Jetpack Compose?
How to get a contact image using a phone number in android?
Hide/Disable soft keyboard on Activity launch: Android
How to get screen size (width,height) in Android?
How to extract date and time from Long type variable in Kotlin on Android "
How to Exit android app on back pressed?
How to validate email address in Android with Kotlin?
How to copy database from assets folder in android using kotlin
INSTALL_FAILED_INVALID_APK: Split lib_slice_9_apk was defined multiple times. It is possible that th
How to start a new activity on button click
ERR_ACCESS_DENIED in Android Webview with sdk 30
What happens next when the device switches between portrait and landscape?
Android FCM not receiving notifications when app is removed from background
What is Context?
Intent for Drive PDF Viewer - How to open PDF in Google Drive with intent
How to save activity State in Android?
How to get an image resource by it's name in android?
What is NetworkOnMainThread Exception?
How to Get bitmap from drawable: Android
How to install/ uninstall apk by command line ADB
Explain Fragment Life Cycle
Key Points to remember while develop the Android Application.
Invoke-customs are only supported starting with android 0 --min-api 26