Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Really curious bug

DavidBoltonDavidBolton GBMember ✭✭
edited July 2020 in Xamarin.Android

Possibly because I'm mixing an int and a float, but it was a subtraction that was completely wrong. These two lines of code were calculating the x position of a menu element. VWidth is int and width is float. I'd had this as a single line expression with (VWidth - width) /2 in the new Vector2 but it kept coming out with a value of 53. VWidth was 800 and width was 270 so it should have been 265. It was only when I created the variable xPos like this that it got it right.

            var xPos = (VWidth - width)/2;
            position = new Vector2( xPos,(VHeight - height) / 5);

This is in Visual Studio 2019 with Xamarin Android 10.3.1.4 and debugging directly on an Android 5.1 API 22 phone.

Sign In or Register to comment.