Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Xamarin.Forms label and button show flashing cursors (before and/or after the controls) when page appearing #10400

Closed
KevinHu-au opened this issue Apr 21, 2020 · 9 comments
Labels
p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/unverified New report that has yet to be verified t/bug 🐛

Comments

@KevinHu-au
Copy link

KevinHu-au commented Apr 21, 2020

Description

Xamarin.Forms label and button show flashing cursors (before and/or after the controls) for 1-2 secs when page appearing, and disappear after that. The label and button are just regular Xamarin.Forms controls (not 3rd party controls)

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE: Visual studio for mac (8.5.3 build 16)
  • Platform Target Frameworks:
    • Android: 10.0
  • Android Support Library Version:
  • Nuget Packages: 28.0.0.3
  • Affected Devices: Samsung A20, Samsung S7 and emulators
    Xamarin.Forms: 4.5.0.530

Screenshots

<
image

!
image
-- If the issue is a visual issue, please include screenshots showing the problem if possible -->

Reproduction Link

Workaround

Did try make the label/button disabled, not help.

@KevinHu-au KevinHu-au added s/unverified New report that has yet to be verified t/bug 🐛 labels Apr 21, 2020
@KevinHu-au KevinHu-au changed the title [Bug] Xamarin.Forms label and button show grey flashing when page appearing [Bug] Xamarin.Forms label and button show grey flashing cursors when page appearing Apr 21, 2020
@KevinHu-au KevinHu-au changed the title [Bug] Xamarin.Forms label and button show grey flashing cursors when page appearing [Bug] Xamarin.Forms label and button show flashing cursors (before and/or after the controls) when page appearing Apr 21, 2020
@jsuarezruiz
Copy link
Contributor

@KevinHu-au Are those labels and buttons inside a template in a CollectionView (or CarouselView)?. In this case, this issue seems to be the same as #7281 or #10294.

@jsuarezruiz jsuarezruiz added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Apr 21, 2020
@eriktack
Copy link

This happens to me if i have a grid inside a collectionview with any row using GridUnitType.Absolute for height, so labels in this row will have the "cursor":
new RowDefinition{Height = new GridLength(20, GridUnitType.Absolute)}
but not labels inside this:
new RowDefinition{Height = GridLength.Star}, // or auto

@Kubion70
Copy link

This workaround may help you with labels.
Create class in android project:

public class CustomLabelRenderer : Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer
{
    public CustomLabelRenderer(Context context)
        : base(context)
    {
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
    {
        base.OnElementChanged(e);

        if (Control == null)
        {
            return;
        }

        Control.HorizontalScrollBarEnabled = false;
        Control.VerticalScrollBarEnabled = false;
    }
}

Then add to android project AssemblyInfo (or over created class namespace if you wish) following code:

[assembly: ExportRenderer(typeof(Label), typeof(CustomLabelRenderer))]

@KevinHu-au
Copy link
Author

KevinHu-au commented Apr 22, 2020

@KevinHu-au Are those labels and buttons inside a template in a CollectionView (or CarouselView)?. In this case, this issue seems to be the same as #7281 or #10294.

There is not a CollectionView or CarouselView on this page. But I do use PancakeViews (https://github.com/sthewissen/Xamarin.Forms.PancakeView) for the white blocks. (But have tried Frame to replace pancakeview, the issue is still there)

The above screen has UI hierarchy roughly like this. A grid with two rows. The first row contains a scroll view, and the second row contains a Xamarin.Forms button. Each white block is a pancake view with a bunch of labels

 <Grid.RowDefinitions>
     <RowDefinition Height="*"/>
     <RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
 <ScrollView>
      <StackLayout>
            <pancake:PancakeView>
                     <StackLayout> 
                            <Label  ..../>
                     </StackLayout>
            </pancake:PancakeView>

            <pancake:PancakeView>
                     <StackLayout> 
                            <Label  ..../>
                     </StackLayout>
            </pancake:PancakeView>
      </StackLayout>
 </ScrollView>

  <!-- The bottom red button-->
  <Button Grid.Row="1"/></Grid> 

@KevinHu-au
Copy link
Author

KevinHu-au commented Apr 22, 2020

This workaround may help you with labels.
Create class in android project:

public class CustomLabelRenderer : Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer
{
    public CustomLabelRenderer(Context context)
        : base(context)
    {
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
    {
        base.OnElementChanged(e);

        if (Control == null)
        {
            return;
        }

        Control.HorizontalScrollBarEnabled = false;
        Control.VerticalScrollBarEnabled = false;
    }
}

Then add to android project AssemblyInfo (or over created class namespace if you wish) following code:

[assembly: ExportRenderer(typeof(Label), typeof(CustomLabelRenderer))]

@Kubion70 . Thanks for your recommendation. It is working perfectly. Thanks for your rescue me out.

@KevinHu-au
Copy link
Author

Did the same for button to fix this issue

@samhouts
Copy link
Member

Duplicate of #9019

@samhouts samhouts marked this as a duplicate of #9019 Apr 23, 2020
@samhouts
Copy link
Member

Duplicate of #9591

@samhouts samhouts marked this as a duplicate of #9591 Apr 23, 2020
@eriktack
Copy link

Thanks @Kubion70, that will work for me until a proper fix is out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/unverified New report that has yet to be verified t/bug 🐛
Projects
None yet
Development

No branches or pull requests

5 participants