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

wrong height in Android ViewRenderer after set targetSdkVersion increase to 28 or higher

$
0
0

Hello,

i have a problem with Xamarin.Android in conjunction with a custom view renderer. When I increase the targetSdk version from 27 to 28 or 29, the renderer returns an incorrect value for the view height. In the Forms part, "OnSizeAllocated" still gets the correct value. But in the OnSizeChanged part of the custom renderer the value for the height is wrong after changing the SDK version. The height grows exponentially to the number of elements contained. I have already tested with several Forms versions, as well as various tips in connection with ClipBounds. Unfortunately without success. Setting layout parameters does not help either, because they are completely ignored. Does anyone else have an idea? I suspect that this is a bug, but maybe I'm just overlooking a necessary change.

public class NativeAndroidDetailViewRenderer : ViewRenderer<CustomFormsView, LinearLayout>, ICleanUpView, ITabProvider
{
    private LinearLayout NativeDetailView { get; set; }
    public CustomFormsView DetailView;


    public NativeAndroidDetailViewRenderer(Context context) : base(context)
    {
        //this.SetWillNotDraw(false);
    }

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


        if (e.OldElement != null)
        {
        }
        if (e.NewElement != null)
        {
            // Subscribe
            if (Control == null)
            {
                DetailView = e.NewElement;
                NativeDetailView = new LinearLayout(Context)
                {
                    Bottom = 0,
                    LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent)
                    {
                        BottomMargin = 0
                    }
                };
                NativeDetailView.SetBackgroundColor(global::Android.Graphics.Color.White);

                NativeDetailView.Orientation = Orientation.Vertical;
                NativeDetailView.Touch += UiDetailView_Touch; 

                Init();

                SetNativeControl(NativeDetailView);
            }
        }
    }
    ....
}

Stefan


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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