Not able to tap on the edges of the Box view

ThavaThava INMember ✭✭
            BoxView ImageTappedArea = new BoxView()
            {
                ClassId = content.id,
                BackgroundColor = Color.FromRgba(255, 255, 0, 0.5),
                //BackgroundColor = Color.Transparent,

                WidthRequest = 60,
                HeightRequest =380,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions = LayoutOptions.Start,
                Rotation = 320,
            };
            Command ValidTapCommand = new Command(() =>
            {
                OnVeiwClicked(ImageTappedArea.ClassId);
            });
            var tgr = new TapGestureRecognizer { };
            tgr.Command = ValidTapCommand;
            ImageTappedArea.GestureRecognizers.Add(tgr);
            absoluteLayout.Children.Add(ImageTappedArea);

I added this box view in the absolute layout, now the problem is i am not able tap the corners of the boxview
i can able to tap the center of the boxview only, what i am doing wrong here
anybody please help me

Posts

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Just a guess... and a test...
    Take out the rotation and see if it behaves.

  • ThavaThava INMember ✭✭

    perfectly working as expected when there is no rotation,
    but when i add the rotation , the edges nearly half the box view is not able to tap, i'm able to tap on the center only

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    It wouldn't be the first time UI elements created in code didn't behave as expected. I've seen other threads for similar things. Try creating your UI in XAML and see if it persists.

    Also... A bug isn't a bug until it happens on a physical device. If you're doing this in an emulator make sure it is still a problem on a real phone or tablet.

    If it persists to a physical device when you make the control in both C# and in XAML then its a genuine bug that you should open in bugzilla - for that matter have you checked to see if it is already a known bug in Bugzilla?

  • ThavaThava INMember ✭✭
    edited June 2017

    OMG, we have already almost completed the project based on code only, we use XAML in very few places only,
    i don't know what i am going to do now

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    OMG - chill dude.

    A - building UI in C# is not really a great idea. Hasn't been since the early days of WPF more than 10 year ago. You only see that sort of bad practice out of Inida outsourcers. But experienced MVVM development teams don't do it.

    B - You don't have to test in your live project. Just make a new "Welcome to Xamarin" project straight from the Visual Studio templates and do the test. If it still fails you then have a nice little reproducable solution you can provide for the Bugzilla report.

  • JohnHardmanJohnHardman GBUniversity mod
    edited June 2017

    @Thava - How accurate does the tap detection need to be? If it doesn't need to be hugely accurate, do some trigonometry to work out the smallest bounding rectangle that would contain your rotated one, overlay the bounding rectangle using transparent color, and add the tap gesture recognizer to that rectangle.

    Or, create custom BoxView renderers for each target platform, with the renderers doing the tap detection even when the underlying control is rotated.

    Alternatively, now that Xamarin.Forms is open source, (assuming it is a bug) you could submit a fix to take rotation into account, but you'd be waiting a while for it to get released.

    Or, to get something working and released, could you make do without the rotation for the first release?

    BTW - does that page support accessibility?

  • ThavaThava INMember ✭✭

    Thanks @ClintStLaurent & @JohnHardman ,
    Gotcha
    I found the problem, The absolute layout and boxview have same width and height , when i rotate the box view the area only belongs to the absolute layout is clickable, (i.e.) the area intersect by boxview and absolute layout is only clickable

    So instead of rotate the boxview, i'm just rotate the absolutelayout, now every thing works as expected
    once again thank you people

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Good job @Thava - Good to see someone that will keep plugging away and make the effort!

  • JohnHardmanJohnHardman GBUniversity mod

    @Thava - If a rotated AbsoluteLayout supports gesture recognizers, it seems reasonable to expect a rotated BoxView to do the same. I recommend raising a bug in Bugzilla.

Sign In or Register to comment.