[android-developers] Re: Is it possible to give gradient effect using code?
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 following using code? If yes, can someone > please give me a sample? > > android:angle="270" > android:startColor="#b3adad" > android:endColor="#858080"> > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Is it possible to give gradient effect using code?
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:23 pm, Ash wrote: > Currently I have an XML file which sets the gradient of the button > background. > Is it possible to achieve the following using code? If yes, can someone > please give me a sample? > > android:angle="270" > android:startColor="#b3adad" > android:endColor="#858080"> > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Is it possible to give gradient effect using code?
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 received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Is it possible to give gradient effect using code?
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 "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Is it possible to give gradient effect using code?
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.Orientation.TOP_BOTTOM, colors); > drawable.setShape(GradientDrawable.RECTANGLE); > drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); > > On Aug 25, 7:23 pm, Ash wrote: >> Currently I have an XML file which sets the gradient of the button >> background. >> Is it possible to achieve the following using code? If yes, can someone >> please give me a sample? >> >> > android:angle="270" >> android:startColor="#b3adad" >> android:endColor="#858080"> >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en