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.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Reply

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