0

I have a shape as the background of my linear layout, that shape is a ring that is in sn XML file in drawable, I'm trying to find out how to change the color of this shape in my C# files, I'm working in Xamarin on Visual Studio for Mac

This is my code:

<?xml version="1.0" encoding="utf-8" ?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:id="@+id/rng">
            <shape
                android:shape="ring"
                android:innerRadius="150dp"
                android:thickness="10dp"
                android:useLevel="false">
            <solid android:color="#ababf2" />

            </shape>
        </item>
    </layer-list>
    ...
Antoine Thiry
  • 2,362
  • 4
  • 28
  • 42
YoavOr
  • 1
  • 2
  • Does this answer your question? [How to make a drawable Shape programmatically (Android)](https://stackoverflow.com/questions/44401777/how-to-make-a-drawable-shape-programmatically-android) – FreakyAli Feb 18 '20 at 12:49
  • You want to know how to change it programmatically? Since I think you can just change it in your XML by putting the hex of the color you desire here – unobatbayar Feb 18 '20 at 12:51
  • Does this answer your question? [Android: Change Shape Color in runtime](https://stackoverflow.com/questions/5940825/android-change-shape-color-in-runtime) – Cheesebaron Feb 18 '20 at 14:09
  • If just need to chaneg background color of `Layout` , only use follow code can do that :`linearLayout.SetBackgroundColor(Android.Graphics.Color.Red);` .I think `shape` is not designed to be changed when runtime . – Junior Jiang Feb 19 '20 at 03:14

0 Answers0