Xamarin.forms: Label layout problem in ListView at Forms3.5

Created on 17 Feb 2019  ·  3Comments  ·  Source: xamarin/Xamarin.Forms

Description

Label in the ListView can't be layout correctly at Android. iOS is ok.

Steps to Reproduce

  1. the xaml like that
    ```




    Margin="20,0,0,0"
    ShowLabel="true"
    Checked="{Binding Check}"
    OnImg="checked_checkbox.png"
    OffImg="unchecked_checkbox.png"
    Text="{Binding Word}" />



2. the CheckBox code like that:
public CheckBox() {
        this.TapCmd = new Command(() => {
            this.Checked = !this.Checked;

            if (this.CheckChanged != null)
                this.CheckChanged.Invoke(this, new EventArgs());

            if (this.CheckChangedCmd != null && this.CheckChangedCmd.CanExecute(this.Checked))
                this.CheckChangedCmd.Execute(this.Checked);
        });


        StackLayout stackLayout = new StackLayout {
            Orientation = StackOrientation.Horizontal
        };


        TapBinder.SetCmd(stackLayout, this.TapCmd);
        this.Content = stackLayout;

        this.Label = new Label() {
            BackgroundColor = Color.Red,
            BindingContext = this,
            VerticalTextAlignment = TextAlignment.Center,
            HorizontalOptions = LayoutOptions.StartAndExpand
        };
        this.Label.SetBinding(Label.TextProperty, "Text");
        this.Label.SetBinding(Label.IsVisibleProperty, "ShowLabel");

        this.Icon = new Image() {
            WidthRequest = this.Size,
            HeightRequest = this.Size,
            Source = this.OffImg
        };
        stackLayout.Children.Add(this.Icon);
        stackLayout.Children.Add(this.Label);

    }

```

Expected Behavior

the text of label can be display normally.

Actual Behavior

the text of some label can't be seen when scoll ListView up or down.

Basic Information

  • Version with issue:

=== Visual Studio Community 2017 for Mac ===

Version 7.7.4 (build 1)
Installation UUID: 4e60959a-758f-48ce-ae6d-26e15276ea83
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

Package version: 516000221

=== Mono Framework MDK ===

Runtime:
Mono 5.16.0.221 (2018-06/b63e5378e38) (64-bit)
Package version: 516000221

=== NuGet ===

Version: 4.8.0.5385

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.8
2.1.7
2.1.2
2.1.1
2.0.5
2.0.0
1.1.1
1.0.4
SDK: /usr/local/share/dotnet/sdk/2.1.504/Sdks
SDK Versions:
2.1.504
2.1.503
2.1.302
2.1.301
2.1.4
2.0.0
1.0.3
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Mac ===

Version: 5.2.1.15 (Visual Studio Community)
Hash: d60abd198
Branch:
Build date: 2019-02-01 12:23:30-0500

=== Xamarin.Android ===

Version: 9.1.8.0 (Visual Studio Community)
Android SDK: /Users/huangboru/myfile/sdk
Supported Android versions:
4.2 (API level 17)
4.4 (API level 19)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.0
SDK Build Tools Version: 28.0.3

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/huangboru/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.9
openjdk version "1.8.0-9"
OpenJDK Runtime Environment (build 1.8.0-9-microsoft-b00)
OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Build Information ===

Release ID: 707040001
Git revision: 2a4679454f31c8bb887cfd181ea133c9149d3cad
Build date: 2019-01-30 16:18:21+00
Build branch: release-7.7.4
Xamarin extensions: c8b4305fd4c60b9c25947072eb150fdc3a5aa2b5

Screenshots


droid-mainactivity-02172019185656

I set the backgroundColor of Label, It seems problem is due to the wrong layout of Label .

droid-mainactivity-02172019193816

Reproduction Link

listview Android needs-info ❓ needs-repro ❔ bug

Most helpful comment

I update the version of Xamarin.Forms to 3.5.169047, the problem has disappeared.

All 3 comments

@suihanhbr Would you please attach a sample project that shows this issue? Thank you!

here is the sample:
TestLabelProblem.zip

this is the first UI. It doesn't display the text normally.
screenshot_2019-02-20-10-10-28-963_com suihan testlabelproblem

if I scroll the listView many times rapidly , it will be like that:

screenshot_2019-02-20-10-10-42-816_com suihan testlabelproblem

@samhouts

I update the version of Xamarin.Forms to 3.5.169047, the problem has disappeared.

Was this page helpful?
0 / 5 - 0 ratings