Skip to content Skip to sidebar Skip to footer

Button On Top Of The Scrollview Does Not Show Up

I have something like this so far for my view: public StackLayout OffersSlideViewCarouselChild(Offer offer) { Image productImage = new Image { Source = ImageSou

Solution 1:

Moving here from comments above. There are two separate issues from what I can tell, and as far as I can tell, are unrelated:

  1. The WebView, nested inside the ScrollView, is not big enough to fully display the content.
  2. The button that is supposed to be at the bottom of the screen is not displaying.

For both of them, the answer is probably in how you are setting HeightRequest. There have been a lot of suggestions by myself and other commenters to change or get rid of some of the HeightRequest settings, and I'm not sure of the current state of your source code. So assuming those are still there:

  1. For solving the WebView issue, read How can I add HTML to a Stacklayout inside a Scrollview in Xamarin forms?. This will let you figure out the right HeightRequest to use. The short answer is that depending on exactly what you want to happen, you may need a custom renderer. Note that the HeightRequest for the WebView will not affect any layout outside of the ScrollView.

  2. For solving the issue of the button not appearing, get rid of the HeightRequest setting on the ScrollView, and the VerticalOptions on the StackLayout created in SavedButtonLayout.

I am assuming you did the experiment suggested above to make sure that the redeemBtn will render if placed before the ScrollView, and it does show up then. If not, you first need to fix that.


Solution 2:

If you have "fixed" this by changing the HeightRequest then your real problem is the fixed pixel size of all your views and layouts, I recommend you DON'T use fixed pixel sizes for different screen resolution this will be a bigger problem later, What you can do is get the Screen size and do the math to fit all your elements of the view, one way to get the width and height of the screen is on the OnSizeChanged event of Pages (Like ContentPage), something like this:

SizeChanged += SizeChanged;
void SizeChanged (object sender, EventArgs e)
{
    Layout.WidthRequest = Width * 0.3;
    Layout.HeightRequest = Height * 0.35;
}

Solution 3:

Your layout is pretty busy. A few things:

  1. Set VerticalOptions to EndAndExpand for redeemBtn.
  2. Set VerticalOptions to StartAndExpand for savedBtn.
  3. Set VerticalOptions to Fill for mainScrollView.
  4. Set VerticalOptions to FillAndExpand for mainRelLayout.
  5. Set VerticalOptions and HorizontalOptions to Fill for mainStackLayout.

I think that will get you to where you want to be.

The options that include "Expand" will grow the element to accommodate the desired height of its contents.


Post a Comment for "Button On Top Of The Scrollview Does Not Show Up"