[android-developers] Re: Is it possible to give gradient effect using code?

2011-08-30 Thread Mike
On Aug 29, 5:53 pm, Ash wrote: > I am trying to get rid of the XML file and do everything using code. Please > let me know if this is possible. That's like swimming upstream - possible but not always an easy task -- You received this message because you are subscribed to the Google Groups "Andr

[android-developers] Re: Is it possible to give gradient effect using code?

2011-08-29 Thread Ash
Thanks for sharing the sample code. Wonderful. What about giving corners to the default Android button. At present I have an xml file which does this I am trying to get rid of the XML file and do everything using code. Please let me know if this is possible. -- You re

Re: [android-developers] Re: Is it possible to give gradient effect using code?

2011-08-29 Thread Matt Powers
Just don't try to draw the gradient in ondraw with hardware acceleration turned on On Aug 26, 2011, at 10:57 AM, Andrew Pierce wrote: > Use a GradientDrawable: > > int[] colors = new int[] { 0xFFB3ADAD, 0xFF858080 }; > GradientDrawable drawable = new > GradientDrawable(GradientDrawable.Orienta

[android-developers] Re: Is it possible to give gradient effect using code?

2011-08-29 Thread Andrew Pierce
Use a GradientDrawable: int[] colors = new int[] { 0xFFB3ADAD, 0xFF858080 }; GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, colors); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); On Aug 25, 7:2

[android-developers] Re: Is it possible to give gradient effect using code?

2011-08-26 Thread blake
Sure! That XML just creates a LinearGradient object. Look here: http://developer.android.com/reference/android/graphics/LinearGradient.html -blake On Aug 25, 5:23 pm, Ash wrote: > Currently I have an XML file which sets the gradient of the button > background. > Is it possible to achieve the