• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why changing Color of Default Button makes it look rectangle?

 
Pritam Shah
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why changing Color of Default Button makes it look RECTANGLE shape ? I do not want to use custom background images for this.
I want to do this programmatically for few conditions on which I change the colors of many small buttons on screen.
Can anyone give a solution ?

P.S. ==> It seems there is no workaround by reading this
http://groups.google.com/group/android-beginners/browse_thread/thread/e1313e2c98e9c52b

or is there any ?
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default button background is a 9-patch drawable as Mark suggested in the linked post.

To paraphrase, specifying a plain background color is different from having a gradient, 9-patch drawable as background.(See discussion here)

AFAICT, you should be able to create 9-patch drawable of the colors that you like and then conditionally set them as button background in code.
 
Pritam Shah
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally got this working. Here is a solution :

For changing color (eg. red):


For removing color :


 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for sharing the solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic