How to create gradient for button in android through java code?

By | November 18, 2011

In the previous post I have showed how to create gradient buttons in android using XML.

This is how we do this in java code.

 Button b = (Button)findViewById(R.id.Button01);
 b.getBackground().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY);
 

This is another method of applying gradiant.

b.getBackground().setColorFilter(new LightingColorFilter(0xFF00FF00, 0xFFAA0000));

Please leave your valuable comments.

One thought on “How to create gradient for button in android through java code?

  1. Pingback: How to show a sliding window from below in Android? | Coderz Heaven

Leave a Reply

Your email address will not be published. Required fields are marked *