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(;
 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 Comment

  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 *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.