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

ScrollView not locked when keyboard shows up

$
0
0

Hi,
I created an app with Xamarin Forms, with a ContentPage builded like so:

`
StackLayout _mainLayout = new StackLayout();
_mainLayout.VerticalOptions = LayoutOptions.Start;-
_mainLayout.Orientation = StackOrientation.Vertical;

_searchBar = new SearchBar ();

_scrollContainer = new RelativeLayout ();

ScrollView _scrollBooks = new ScrollView ();
_scrollBooks.Orientation = ScrollOrientation.Horizontal;

_scrollLayout = new StackLayout ();
_scrollLayout.Orientation = StackOrientation.Horizontal;
_scrollLayout.Padding = new Thickness (20, 40);

_startLoader = new ActivityIndicator ();
_startLoader.IsRunning = true;

_scrollBooks.Content = _scrollLayout;

_scrollContainer.Children.Add(_scrollBooks,
Constraint.Constant (0),
Constraint.Constant (0),
Constraint.RelativeToParent ((parent) => { return parent.Width; }),
Constraint.RelativeToParent ((parent) => { return parent.Height; }));

_scrollContainer.Children.Add(_startLoader,
Constraint.Constant (0),
Constraint.Constant (0),
Constraint.RelativeToParent ((parent) => { return parent.Width; }),
Constraint.RelativeToParent ((parent) => { return parent.Height; }));

_mainLayout.Children.Add (_searchBar);
_mainLayout.Children.Add (_scrollContainer);

`
All is working perfect, but when i click on the search box and the keyboard shows up, the scroll view is no more locked in horizontal direction but it scrolls also in vertical.
I believe this problem was generated becouse the view resizes and the StackLayout scrolls in any direction. (I'll attach an image to better understand).

Which could be a better way to solve this problem?

Thanks in advance.

Marco


Viewing all articles
Browse latest Browse all 58056

Trending Articles