We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GradientView in Android statusBar

Hi,

Is it possible to set the Android StatusBar BackgroundColor in Gradient, when using shell, with the GradientView?


Thank you,

Helder Correia


3 Replies

ET Eswaran Thirugnanasambandam Syncfusion Team April 12, 2023 09:42 AM UTC

Hi Helder Correia,


Your requirement can be achieved by adding a custom render to the app shell as mentioned in the below code snippet

[C#]

[assembly: ExportRenderer(typeof(AppShell), typeof(CustomShellRenderer))]

namespace GradientShell.Droid

{

    public class CustomShellRenderer : ShellRenderer

    {

        public CustomShellRenderer(Context context) : base(context)

        {

        }

 

        protected override IShellToolbarAppearanceTracker CreateToolbarAppearanceTracker()

        {

            return new CustomToolbarAppearanceTracker();

        }

    }

 

    // Toolbar appearance

    public class CustomToolbarAppearanceTracker : IShellToolbarAppearanceTracker

    {

        public void Dispose()

        {

 

        }

 

        public void ResetAppearance(AndroidX.AppCompat.Widget.Toolbar toolbar, IShellToolbarTracker toolbarTracker)

        {

        }

 

        public void SetAppearance(AndroidX.AppCompat.Widget.Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance)

        {

            toolbar.SetBackgroundResource(Resource.Drawable.custom_gradient);

        }

    }

}


[XAML]

<?xml version="1.0" encoding="utf-8" ?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"

 android:shape="rectangle">

 

                <gradient

                 android:type="linear"

                 android:startColor="#2d265b"

                 android:endColor="#b8495c"

                 android:angle="270"/>

</shape>



We have prepared a sample to achieve your requirement and please get it from below attachment. For more details, please refer the below link.

https://social.msdn.microsoft.com/Forums/en-US/1037d0d0-55d9-4771-be55-8f640e0e0d1f/shell-navigation-bar-gradient?forum=xamarinforms


Regards,

Eswaran


Attachment: GradientShell_9645f4c9.zip


HE Helder replied to Eswaran Thirugnanasambandam April 12, 2023 02:12 PM UTC

Thank you, its perfect.



PR Preethi Rajakandham Syncfusion Team April 13, 2023 04:41 AM UTC

Hi Helder,

Thank you for the update.

We are glad that the provided response meets your requirements. Please let us know if you need further assistance. As always, we are happy to help you out.

Regards,

Preethi R


Loader.
Up arrow icon