shape

Set android shape color programmatically

巧了我就是萌 提交于 2019-11-26 05:48:30
问题 I am editing to make the question simpler, hoping that helps towards an accurate answer. Say I have the following oval shape: <?xml version=\"1.0\" encoding=\"utf-8\"?> <shape xmlns:android=\"http://schemas.android.com/apk/res/android\" android:shape=\"oval\"> <solid android:angle=\"270\" android:color=\"#FFFF0000\"/> <stroke android:width=\"3dp\" android:color=\"#FFAA0055\"/> </shape> How do I set the color programmatically, from within an activity class? 回答1: Note : Answer has been updated

How to change shape color dynamically?

白昼怎懂夜的黑 提交于 2019-11-26 00:59:01
问题 I have <?xml version=\"1.0\" encoding=\"utf-8\"?> <shape xmlns:android=\"http://schemas.android.com/apk/res/android\" android:shape=\"rectangle\"> <solid android:color=\"#FFFF00\" /> <padding android:left=\"7dp\" android:top=\"7dp\" android:right=\"7dp\" android:bottom=\"7dp\" /> </shape> <TextView android:background=\"@drawable/test\" android:layout_height=\"45dp\" android:layout_width=\"100dp\" android:text=\"Moderate\" /> So now I want this shape to change colors based on information I get

Set android shape color programmatically

做~自己de王妃 提交于 2019-11-25 18:50:40
I am editing to make the question simpler, hoping that helps towards an accurate answer. Say I have the following oval shape: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:angle="270" android:color="#FFFF0000"/> <stroke android:width="3dp" android:color="#FFAA0055"/> </shape> How do I set the color programmatically, from within an activity class? Vikram Note : Answer has been updated to cover the scenario where background is an instance of ColorDrawable . Thanks Tyler Pfaff , for pointing this out.