Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Android Custom Frame Renderer Help

$
0
0

Hello Community,

I created a custom FRAME renderer that creates a gradient background. It works for iOS however in Android the gradient works but none of the child controls inside the frame display. Can someone tell me what I am doing wrong that causes the child controls to not display?

`

protected override void OnElementChanged( ElementChangedEventArgs<Frame> e )
    {
        base.OnElementChanged( e );

        if( e.OldElement != null || Element == null )
            return;

        Background = GetGradientDrawable();
    }

private GradientDrawable GetGradientDrawable()
    {
        Xamarin.Forms.Color[] gradientColors = new Xamarin.Forms.Color[ 2 ];
        gradientColors[ 0 ] = Card.StartColor;
        gradientColors[ 1 ] = Card.EndColor;

        int[] androidColors = new int[ gradientColors.Length ];
        for( int i = 0; i < gradientColors.Length; i++ )
        {
            Xamarin.Forms.Color temp = gradientColors[ i ];
            androidColors[ i ] = temp.ToAndroid();
        }

        GradientDrawable gradient = new GradientDrawable( GradientDrawable.Orientation.LeftRight, androidColors );
        gradient.SetCornerRadii( new float[] { Element.CornerRadius, Element.CornerRadius, Element.CornerRadius, Element.CornerRadius,
            Element.CornerRadius, Element.CornerRadius, Element.CornerRadius, Element.CornerRadius } );

        return gradient;
    }

`

Thank you in advance for the help.
Chris


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>