Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3676884
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:09:15+00:00 2026-05-19T03:09:15+00:00

I have an android app on which, when the user taps a TextView ,

  • 0

I have an android app on which, when the user taps a TextView, I would like to apply a defined style.

I thought to find a textview.setStyle() but it doesn’t exists. I tried

textview.setTextAppearance();

but it does not work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:09:16+00:00Added an answer on May 19, 2026 at 3:09 am

    I did this by creating a new XML file res/values/style.xml as follows:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <style name="boldText">
            <item name="android:textStyle">bold|italic</item>
            <item name="android:textColor">#FFFFFF</item>
        </style>
    
        <style name="normalText">
            <item name="android:textStyle">normal</item>
            <item name="android:textColor">#C0C0C0</item>
        </style>
    
    </resources>
    

    I also have an entries in my “strings.xml” file like this:

    <color name="highlightedTextViewColor">#000088</color>
    <color name="normalTextViewColor">#000044</color>
    

    Then, in my code I created a ClickListener to trap the tap event on that TextView:
    EDIT:
    As from API 23 ‘setTextAppearance’ is deprecated

        myTextView.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View view){
                        //highlight the TextView
                        //myTextView.setTextAppearance(getApplicationContext(), R.style.boldText);
        if (Build.VERSION.SDK_INT < 23) {
           myTextView.setTextAppearance(getApplicationContext(), R.style.boldText);
        } else {
           myTextView.setTextAppearance(R.style.boldText);
        }
         myTextView.setBackgroundResource(R.color.highlightedTextViewColor);
                    }
                });
    

    To change it back, you would use this:

    if (Build.VERSION.SDK_INT < 23) {
        myTextView.setTextAppearance(getApplicationContext(), R.style.normalText);
    } else{
       myTextView.setTextAppearance(R.style.normalText);
    }
    myTextView.setBackgroundResource(R.color.normalTextViewColor);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting an Android app which will have multiple Activities. It will be using
I am new to android. I have a loginActivity which validates a user number
I have an app which displays a large amount of text for the user
I would like to write an app on Android to upload my GPS location
I have an application for Android which communicates with a Google App Engine (GAE)
I am currently developing an android app. I have an activity which calls a
I am building an Android app in which user are required to choose a
I have a service class in my Android app which uses a timer. The
I was wondering, i have an android app that a user fills in details
I am developing an Android app which needs to poll a specific webpage in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.