Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Creating a simple parallax

$
0
0

Hey,

I want to create a simple parallax with two or three views sliding at a different speed.
I thought about using a RelativeLayout and relocate the views by a timed event (System.Timers). But this leads me to two problems:
First I can't use the RelativeLayout correctly. When I create a View (for example a textview) the width property is always -1.. Therefore I can't do something like

relativeLayout.Children.Add (title,
    Constraint.RelativeToParent ((parent) => {
        return parent.X - parent.X / 2 - title.Width;
    }),
    Constraint.RelativeToParent ((parent) => {
        return parent.Y - parent.Y / 2 - title.Width;
    }))
);

Like this only the upper-left corner is centered in the relative layout but not the whole text.

The second problem is that I haven't found a methode to relocate the view. Therefore I need to remove the view and then add it again with a new position. But then I get a runtime exception that only the thread which created the relative layout is allowed to change it..

Has anyone already created something like this or has an idea how to create a parallaxe with forms?


Viewing all articles
Browse latest Browse all 58056

Trending Articles