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

  • Home
  • SEARCH
  • 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 8096641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:31:00+00:00 2026-06-05T21:31:00+00:00

On an Android View, I want to have a some clickable text that works

  • 0

On an Android View, I want to have a some clickable text that works similar to a webpage hyperlink.

It looks just like normal text (no button border), but when touched, I want the text color to change and I may also want its background to turn a reverse color.

Is it better to use a Button with a transparent background or a TextView. When should I choose one over the other?

Thanks much

  • 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-06-05T21:31:02+00:00Added an answer on June 5, 2026 at 9:31 pm

    hotveryspicy gave a great answer and really pointed me in the right direction. Thank you, but I had a few issues with the response.

    What I want is a button that has Black text and a Gray background in its normal state and a Red background with White text in its selected state. Like this:

    enter image description here

    Using hotveryspicy’s suggestions I had the following issues:

    1. I get an error when trying to assign a drawable to textColor. Funny but I see other references to doing this sort of thing. Maybe the XML validation is stricter now?

    2. I also got an error if I didn’t define a android:drawable in the buttonselector.xml. It seems you can set the color of a drawable in a selector eiter, you need to actually create a drawable.

    Anyhow this is what I did:

    I created a Color State Resource that looks like this:

    File: res/colors/link_button.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="#ffffff"/> 
        <item android:color="#000000"/> 
    </selector>
    

    Then the following 3 drawables:

    My button background in its normal state using a Shape Drawable:
    File: res/drawable/link_button.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
        android:shape="rectangle">
        <solid  android:color="#cccccc"/>
    </shape>
    

    My button background in its selected state, also a Shape Drawable:
    File: res/drawable/link_button_selected.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
        android:shape="rectangle">
        <solid  android:color="#ff0000"/>
    </shape>
    

    Then I created a Drawable Selector that chooses between the 2 shapes.
    File: res/drawable/link_button_selector.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    
     <item 
         android:drawable="@drawable/link_button_selected"
         android:state_pressed="true" />
    
     <item 
         android:drawable="@drawable/link_button" />
    </selector>
    

    Then in my layout my button looks like this:

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:text="Button"
        android:textColor="@color/link_button" 
        android:background="@drawable/link_button_selector"
        />
    

    Thanks for the help everyone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my android application I have some buttons that launch the native browser to
I have an application, which has a Spinner that I want populated with some
in my android app i am using expandable list view to display some text.These
i have created a login page for some application in android and i want
I just started with Android and I'm doing a simple app that I want
I want to create a set of objects which inherit from some Android View
What I have here is a custom view and then I want some widgets
I want to show a button at the end of an Android list view.
I want to implement Paginated list View in android so when I scroll down
I want to display html in android activity through web view,my screen will be

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.