Relative layout not over lapping other views (Xamarin.Forms)

Hi
I am trying to build my own autocomplete control as the ones I tried did not have all the functionality I needed. I simply have the Entry view and a list view which becomes visible when user enters text. This all works fine. However the list when it becomes visible, it pushes the controls below it rather than overlapping them. I have placed the entry and the list in a relative layout. The autocomplete control is then placed within a grid row on the page.

Can someone please guide me on how I can get the list to overlap the view rather than pushing it out of the way.

Below is the code that I have used to place the entry and list in relative layout

        innerRelativeLayout.Children.Add(entText,
            Constraint.RelativeToParent((parent) => { return parent.X; }),
            Constraint.RelativeToParent((parent) => { return parent.Y; }),
            Constraint.RelativeToParent((parent) => { return parent.Width; }),
            Constraint.RelativeToParent((parent) => { return parent.Height; }));

        innerRelativeLayout.Children.Add(lstSugestions,
            Constraint.RelativeToView(entText, (parent, view) => { return view.X; }),
            Constraint.RelativeToView(entText, (parent, view) => { return view.Y + 38; }),
            Constraint.RelativeToView(entText, (parent, view) => { return view.Width; }),
            Constraint.RelativeToView(entText, (parent, view) => { return 250; }));

        Content = innerRelativeLayout;

Answers

  • StefaanAvonds.3725StefaanAvonds.3725 USMember ✭✭✭

    Are the other controls also placed inside this RelativeLayout?

  • AmiteshSharma.5497AmiteshSharma.5497 NZMember ✭✭

    No the other controls are in grid layout. The autocomplete control I am building is a custom control which can be used on any page. Like I said I have an entry and list view that makes up the custom control. Both of these are placed in relative layout. I then want to place the control on any page which will have other controls but mostly in grid layout.

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai

    @AmiteshSharma.5497,

    My guess right now is that this is not working as you expect because when you place the control on a Page, it's going to be a RelativeLayout nested inside whatever Content that Page has. Instead, inside your custom control, you would need to access the parent Page and add a RelativeLayout to it for this controls ListView to overlap the Pages content too. That's similar to how this control works.

  • Hi John
    Thanks for our reply but I didnt understand what you were trying to explain. Could you please elaborate.

  • NageshDegilNageshDegil USMember ✭✭

    Hi,

    I'm trying to implement AutoCompleteView in Xamarin forms. When user types some characters in the entry, the overlapping list view should appear on above to Entry field as displayed in screen.
    I implemented logic like when user types input listview should show retarded values.
    Anyone tells what's constraints need to give to Listview in Relative layout.

Sign In or Register to comment.