Cannot Access WindowInsets

Nathan Sokalski 4,116 Reputation points

I am attempting to access the WindowInsets in my app, but I am receiving the following message:

Java.Lang.NoSuchMethodError: 'no static method "Landroid/view/WindowInsets$Type;.statusBars()I"'

The expression in my code containing this is (frmPossibleBids is a FrameLayout):


What am I doing wrong?

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,208 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 58,496 Reputation points Microsoft Vendor


    If you want to get WindowInsets, your frmPossibleBids should be attached in the layout.

    So, I add a AddOnAttachStateChangeListener for frmPossibleBids, I can get the top value in the OnViewAttachedToWindow method like following code.

       //add AddOnAttachStateChangeListener  
                   frmPossibleBids.AddOnAttachStateChangeListener(new FrmPossibleBidsttachStateChangeListener());  
       // achieve this AddOnAttachStateChangeListener class.  
       internal class FrmPossibleBidsttachStateChangeListener : Java.Lang.Object, View.IOnAttachStateChangeListener  
               public void OnViewAttachedToWindow(View attachedView)  
                 var topValue= attachedView.RootWindowInsets.GetInsets(WindowInsets.Type.StatusBars()).Top;  
               public void OnViewDetachedFromWindow(View detachedView)  

    Best Regards,

    Leon Lu

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful