I actually didn't need to set the RoundRectShape, just using the PaintDrawable with the constructor taking a color and then setting the Radii did the trick. Thanks a lot
On Nov 28, 1:42 am, Kostya Vasilyev <[email protected]> wrote: > There is only one background per view - if you use a color value or an > image, it replaces the background shape you set in XML. > > To set a new shape-type background: > > Create a PaintDrawable with a RoundRectShape in it: > > http://developer.android.com/reference/android/graphics/drawable/Pain... > > http://developer.android.com/reference/android/graphics/drawable/shap... > > Then use view.setBackgroundDrawable with the PaintDrawable you created > above: > > > public void setBackgroundDrawable (Drawable d) > > Since: API Level 1 > > > Set the background to a given Drawable, or remove the background. > > -- Kostya > > 28.11.2010 10:10, Android808 пишет: > > > > > > > > > > > I am using a shape defined as a drawable as background for a TextView. > > This allows me to add rounded corners and other other effects. > > The shape is defined like this: > > > <?xml version="1.0" encoding="utf-8"?> > > <shape xmlns:android="http://schemas.android.com/apk/res/android" > > android:shape="rectangle"> > > <corners android:topLeftRadius="8dp" /> > > </shape> > > > and I am using it like this: > > > <TextView > > android:id="@+id/project" > > style="@style/textView" > > android:background="@drawable/project_textview_background" > > /> > > > Now, I need to change the color of that TextView programmatically > > depending on some conditions. The conditions are note related to > > button states like focuses, selected, etc... It depends on the data. > > My current workaround was to create a 9-patch image for each color but > > I don't like this solution because there are 12 colors and I want to > > use them in other places with different shapes. I'll end up with > > dozens of 9-patch images for something that could be done in code. > > > - I tried to do setBackgroundColor but that seems to overwrite the > > background I previously defined so it doesn't show the rounded corners > > anymore. > > - I looked at a bunch of other API methods but got nowhere > > > Any help would be very much appreciated. Thank you > > Any ideas? > > -- > Kostya Vasilyev -- WiFi Manager + pretty widget > --http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

