How to not let ImageButton get stretched sideways.

chunggchungg Member ✭✭
edited February 13 in Xamarin.Forms

On the iPhone 11:
On iPad Pro:

I have these search bars and image buttons using Xamarin Forms, but the image button is getting stretched out, and I don't know how I can fix it with the XAML set up that I have.

` <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="40" />
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="Auto" />
      </Grid.ColumnDefinitions>

  <SearchBar Grid.Row="0" Grid.Column="0"
             Placeholder="Search"
             Text="{Binding SearchText}"
             FontSize="Medium"
             VerticalOptions="Center"
             Margin="0,4,0,0"/>
  <ImageButton Grid.Row="0" Grid.Column="1" 
               Margin="4,5,4,4"
               Aspect="AspectFit"
               Command="{Binding Filter}" Source="filter.png" BackgroundColor="Transparent">`

The problem is, that if I set the image button to a specific width, to make it universal among devices, I don't know how to tell XAML to just stretch the search bar up to the image. What can I do?

The Android phones and tablets both look like it's supposed to.

Best Answer

Answers

  • chunggchungg Member ✭✭
    edited February 13


    This is actually what the picture looks like on the tablet, it's squished, not stretched. I had the stretching problem earlier.

    edit: I'm not sure why there's just a blank space between the search bar and the image, if the image just took up that space like it should, there'd be no problem.

  • MogspogsMogspogs Member ✭✭

    This seems to be an issue on IOS: Bug Report

    Downgrading Xamarin version to 4.3.0.908975 or earlier fixes the issue but obviously not an ideal solition

  • chunggchungg Member ✭✭

    @ColeX That worked thanks! I did have to add a few margins to make it look better but it did stop stretching and squishing so much.

Sign In or Register to comment.