[Bug] HorizontalOptions="End" and sub-pixel widths
#7,071 opened on Aug 6, 2019
Repository metrics
- Stars
- (5,644 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
Description
I have a grid with two columns, one Auto and one *. I place an element with sub-pixel width (for example a Label with varying text) in the first column and in the second column, I place another element with HorizontalOptions="End". I expect the latter element to be placed as far to the right as possible, but sometimes, it's shifted by one pixel.
Steps to Reproduce
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
BackgroundColor="Black">
<ContentPage.Content>
<StackLayout Spacing="0" HorizontalOptions="Start" WidthRequest="30" BackgroundColor="White">
<Grid HeightRequest="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ContentView>
<BoxView WidthRequest="10" BackgroundColor="Black"/>
</ContentView>
<ContentView Grid.Column="1" HorizontalOptions="End">
<BoxView WidthRequest="10" BackgroundColor="Red"/>
</ContentView>
</Grid>
<Grid HeightRequest="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ContentView>
<BoxView WidthRequest="10.2" BackgroundColor="Black"/>
</ContentView>
<ContentView Grid.Column="1" HorizontalOptions="End">
<BoxView WidthRequest="10" BackgroundColor="Red"/>
</ContentView>
</Grid>
<Grid HeightRequest="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ContentView>
<BoxView WidthRequest="10.4" BackgroundColor="Black"/>
</ContentView>
<ContentView Grid.Column="1" HorizontalOptions="End">
<BoxView WidthRequest="10" BackgroundColor="Red"/>
</ContentView>
</Grid>
<Grid HeightRequest="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ContentView>
<BoxView WidthRequest="10.6" BackgroundColor="Black"/>
</ContentView>
<ContentView Grid.Column="1" HorizontalOptions="End">
<BoxView WidthRequest="10" BackgroundColor="Red"/>
</ContentView>
</Grid>
</StackLayout>
</ContentPage.Content>
</ContentPage>
That is, the only thing that changes from Grid to Grid is the width of the BoxView in the first column using values of 10, 10.2, 10.4, 10.6 to simulate sub-pixel widths for example from a label
Expected Behavior
The red BoxView in the second column with HorizontalOptions="End" should always be placed at the right edge.
Actual Behavior
Depending on the sub-pixel value, some white background pixels are between the red BoxView and the black page background.
Basic Information
- Version with issue: 4.1.0.618606
- Last known good version: n/a
- IDE: Visual Studio 16.2.0
- Platform Target Frameworks:
- iOS: not tested
- Android: 9.0
- Nuget Packages:
- Affected Devices: Samsung SMG390F, Simulator with "Pie 9.0"
Screenshots
