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 6793105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:03:39+00:00 2026-05-26T18:03:39+00:00

How to change the button text color and button shape(rectangle) dynamically/programmatically?

  • 0

How to change the button text color and button shape(rectangle) dynamically/programmatically?

  • 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-26T18:03:40+00:00Added an answer on May 26, 2026 at 6:03 pm

    If you have a button in your main.xml with id=button1 then you can use it as follows:

    setContentView(R.layout.main);
    
    Button mButton=(Button)findViewById(R.id.button1);
    mButton.setTextColor(Color.parseColor("#FF0000")); // custom color
    //mButton.setTextColor(Color.RED); // use default color
    mButton.setBackgroundResource(R.drawable.button_shape);
    

    R.drawable.button_shape(button_shape.xml):

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
      <gradient
          android:startColor="#70ffffff"
          android:centerColor="#70ffffff"
          android:endColor="#70ffffff"
          android:angle="270" />
      <corners 
            android:bottomRightRadius="8dp"
            android:bottomLeftRadius="8dp"
            android:topLeftRadius="8dp"
            android:topRightRadius="8dp"/>  
    </shape>
    

    You can have your own shape file.change it according to your need.

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

Sidebar

Related Questions

I'm wondering if it's possible to change the color of a WinForm Button's text.
Is it possible to change the color of text in a Facebook like button?
i'm trying to change the Text on the BUTTON dynamically which is in the
I want to change the Text of the browse button in the FileUpload Control
I want to change the text of a radio button (HTML element), not an
Is it possible to change the text color of a textview if the textview
Right now I am trying to change the background color of a org.eclipse.swt.widgets.Button with
I want to change the text color of 10-15 TextView 's in my app,
I want a string of text to change color from default to #c30 when
I want to change the text color of <li> one by one when I

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.