How to Highlight Text in Android TextView?

Written by Biajid

Hi there, I'm Biajid, a devoted tech lover who specializes in tackling technical difficulties relate...

   Review by Android Sparks

Hi there, I'm androidsparks, a devoted tech lover who specializes in tackling technical difficulties...


Last Updated: May 20, 2023

Sometimes we need to indicate focus on a particular line or words of a document while reading text on Android. The text highlighter is one of the most used features on different Android Apps. You may find this popular function in different educational note-taking pdf reader applications on Android.

The main use of text highlighter is to indicate a word or sentence and is also used for keyword research on Android. This article will discuss how to highlight text in Android textview and how we can implement this feature in Android Applications. So, stick to the article and read through it carefully.

How to highlight text on Android?

You can easily highlight texts on your Android by following some simple steps. Follow the instructions below if you want to highlight texts on your Android–

  • Open an app or a document on your device that contains the text. (i.e. Gmail)
How to Highlight Text in Android TextView
  • Long tap on the text that you want to highlight. Two tear-drop sliders will appear.
How to Highlight Text in Android TextView
  • Touch the right slider and drag it over the text you want to highlight. Release the slider if completed highlighting.
How to Highlight Text in Android TextView
  • Then, there you may find three options, respectively “Select All,” “Copy,” and “Share.”
How to Highlight Text in Android TextView
  • Now, take any option you want.

How to implement the Text highlight feature on Android?

This part of the article will provide you with a step-by-step guide to implementing the text highlight feature on your Android. Follow the instructions below to implement the text highlight feature on your Android–


Step-by-step guide

Step 1: Create a “New Project”  and choose “JAVA” as the programming language on the Android Studio.

Step 2: Add dependency of Text Highlighter in the “build.gradle” file.

Step3: Go to gradle scripts> build.gradle (Module).

Step 4: Add “ implementation ‘” in the build.gradle file in the dependencies tab.

Step 5: Now, tap on the “Sync now” button to sync your file to build.gradle().

Step6: Open the activity_main.xml file and create a Text Highlighter in it. Add the following lines below to the XML file.

<?xml version="1.0" encoding="utf-8"?>







    <!--Scroll view for scrolling-->






        <!--Linear layout to arrange elements one below another-->





            <!--TextView to display text-->







                android:text="Android is a mobile operating system based on a modified version of the Linux kernel and other open source software, designed primarily for touchscreen mobile devices such as smartphones and tablets. Android is developed by a consortium of developers known as the Open Handset Alliance and commercially sponsored by Google. It was unveiled in November 2007, with the first commercial Android device launched in September 2008.

 It is free and open source software; its source code is known as Android Open Source Project (AOSP), which is primarily licensed under the Apache License. However most Android devices ship with additional proprietary software pre-installed,[10] most notably Google Mobile Services (GMS)[11] which includes core apps such as Google Chrome, the digital distribution platform Google Play and associated Google Play Services development platform. About 70 percent of Android smartphones run Google's ecosystem;[12] competing Android ecosystems and forks include Fire OS (developed by Amazon) or LineageOS. However the 'Android' name and logo are trademarks of Google which impose standards to restrict 'uncertified' devices outside their ecosystem to use Android branding.[13][14]

The source code has been used to develop variants of Android on a range of other electronics, such as game consoles, digital cameras, portable media players, PCs and others, each with a specialized user interface. Some well known derivatives include Android TV for televisions and Wear OS for wearables, both developed by Google. Software packages on Android, which use the APK format, are generally distributed through proprietary application stores like Google Play Store, Samsung Galaxy Store, and Huawei AppGallery, or open source platforms like Aptoide or F-Droid.

Android has been the best-selling OS worldwide on smartphones since 2011 and on tablets since 2013. As of May 2017, it has over two billion monthly active users, the largest installed base of any operating system, and as of August 2020, the Google Play Store features over 3 million apps.[15] The current stable version is Android 11, released on September 8, 2020. " />



    <!--Button to search text-->









        android:text="Search" />

    <!--EditText to give text input-->











        android:text="" />


Step 7: Now, open the file and write the following code inside the file.


import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;



public class MainActivity extends AppCompatActivity {

    // Variable for button,

    // edit text and text view given

    Button button;

    EditText editText;

    TextView textView;


    protected void onCreate(Bundle savedInstanceState) {



        // Accepted through Id's

        button = (Button) findViewById(;

        editText = (EditText) findViewById(;

        textView = (TextView) findViewById(;

        button.setOnClickListener(new View.OnClickListener() {


            public void onClick(View view) {

                new TextHighlighter()




                        .highlight(editText.getText().toString(), TextHighlighter.BASE_MATCHER);





Step 8: Now, open the AndroidManifest.xml file and add the following line to it:


Step 9: Write the code below into the AndroidManifest.xml –

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android=""









        <activity android:name=".MainActivity"



                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />





Step 10: Done. You have successfully implemented the text highlight feature on your Android app.


How can I highlight something on my Android?

You can highlight something on your Android device by just using your fingers. To highlight any text on your Android device, tap on the text and drag over the line or words from the text you need to highlight.

Which app can I install to highlight text on Android?

There are many different applications for Android that support text highlighting. The best choice is to use the in-built text viewer or pdf reader app on your Android. Besides, you can search for Android text highlighter on the Google play store and install the app that fills your requirements.

Why should I highlight text on Android?

Text highlighting is a popular feature on Android that users can use to seek attention to the critical and sensitive information in a document and text. Highlighting is effective because it allows the readers to find out the main points and asks them to take out the important parts only.

How do I highlight text on my Samsung phone?

There are several ways to highlight text on Samsung phones. To highlight any text on your Android device, tap on the text and drag over the line or words from the text you need to highlight.

Final Words

So, that was all about highlighting text in the Android text view. Hopefully, this article on how to highlight text in Android textview has helped you highlight texts on your Android device. If you face any issues while executing the, let us know in the comment section.


Hi there, I'm Biajid, a devoted tech lover who specializes in tackling technical difficulties related to Android phones and operating systems. Over the years, I've gained extensive experience in resolving complex issues and have become a seasoned expert in the field. I'm delighted to have you on my website, and I'm confident that the resources and solutions provided here will prove to be valuable to you

UnhelpfulMostly unhelpfulPossibly helpfulMostly helpfulVery helpful (No Ratings Yet)

Last Updated: May 20, 2023

Post View : 220

Recent Posts