Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] FontImage Icon fails on Android in certain situations #9371

Closed
wagenheimer opened this issue Jan 30, 2020 · 5 comments
Closed

[Bug] FontImage Icon fails on Android in certain situations #9371

wagenheimer opened this issue Jan 30, 2020 · 5 comments

Comments

@wagenheimer
Copy link

wagenheimer commented Jan 30, 2020

Description

FontImage Icon fails on Android in certain situations. In certain situations, it works.
I attached an example where the problem happens.

Using this code the Icons does not work:

 <FlyoutItem
        Title="Main"
        FlyoutDisplayOptions="AsMultipleItems"
        Route="menu">

        <ShellContent
            Title="Items"
            ContentTemplate="{DataTemplate local:ItemsPage}"
            Icon="{FontImage Glyph={x:Static fontawesome:FontAwesomeIcons.List},
                             FontFamily={StaticResource FontAwesomeLight},
                             Color='White'}" />



        <ShellContent
            Title="About"
            ContentTemplate="{DataTemplate local:AboutPage}"
            Icon="{FontImage Glyph={x:Static fontawesome:FontAwesomeIcons.CalendarAlt},
                             FontFamily={StaticResource FontAwesomeLight},
                             Color='White'}" />

    </FlyoutItem>

The icons are not visible and Output Windows displays the following error :

java.lang.IllegalArgumentException: width and height must be > 0
	at android.graphics.Bitmap.createBitmap(Bitmap.java:969)
	at android.graphics.Bitmap.createBitmap(Bitmap.java:948)
	at android.graphics.Bitmap.createBitmap(Bitmap.java:915)
	at crc643f46942d9dd1fff9.ShellFlyoutRecyclerAdapter.n_onBindViewHolder(Native Method)
	at crc643f46942d9dd1fff9.ShellFlyoutRecyclerAdapter.onBindViewHolder(ShellFlyoutRecyclerAdapter.java:48)
	at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6781)
	at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6823)
	at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5752)
	at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6019)
	at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
	at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
	at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
	at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
	at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
	at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
	at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
	at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
	at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4194)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:142)
	at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:41)
	at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1556)
	at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:888)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1255)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at crc643f46942d9dd1fff9.PlatformRenderer.n_onLayout(Native Method)
	at crc643f46942d9dd1fff9.PlatformRenderer.onLayout(PlatformRenderer.java:63)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at com.android.internal.policy.DecorView.onLayout(DecorView.java:887)
	at android.view.View.layout(View.java:18798)
	at android.view.ViewGroup.layout(ViewGroup.java:5951)
	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2648)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2364)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1515)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7091)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927)
	at android.view.Choreographer.doCallbacks(Choreographer.java:702)
	at android.view.Choreographer.doFrame(Choreographer.java:638)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913)
	at android.os.Handler.handleCallback(Handler.java:751)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6682)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

I can confirm that everything was working at least until Xamarin Forms 4.4.0.1203-nightly.

Steps to Reproduce

  1. Execute the Attached Project
  2. Open the Flyout Menu. You will see only the text and no Icons. Check the Output Window, you will find 2 "width and height must be > 0" errors.

Expected Behavior

Icons do appears on Flyout Menu.

Actual Behavior

No Icons does appear on Flyout Menu.

Basic Information

  • Version with issue: Xamarin Forms 4.5.0.187-pre2
  • Last known good version: Xamarin Forms 4.4.0.1203-nightly
  • IDE: Visual Studio 2019
  • Platform Target Frameworks:
    • Android: 9.0

Screenshots

Screenshot_20200130-131711

Reproduction Link

https://www.dropbox.com/s/s2olx9bga5m18sk/ShellIconProblem.zip?dl=0

@wagenheimer wagenheimer added s/unverified New report that has yet to be verified t/bug 🐛 labels Jan 30, 2020
@pauldipietro pauldipietro added this to New in Triage Jan 30, 2020
@samhouts samhouts added this to the 4.5.0 milestone Jan 30, 2020
@samhouts samhouts added a/shell 🐚 e/2 🕑 2 and removed s/unverified New report that has yet to be verified labels Jan 31, 2020
@samhouts samhouts added this to To do in Sprint 165 via automation Jan 31, 2020
@hartez hartez removed this from New in Triage Jan 31, 2020
@PureWeen
Copy link
Contributor

PureWeen commented Feb 1, 2020

@wagenheimer This looks like it's an issue with how the StaticResource gets mapped to the FontImageSource

If you add a Size parameter

FontFamily={StaticResource FontAwesomeLight},
                            Size=16,
                             Color='White'}"

Then they all render correctly

@PureWeen
Copy link
Contributor

PureWeen commented Feb 1, 2020

@wagenheimer
Copy link
Author

@wagenheimer This looks like it's an issue with how the StaticResource gets mapped to the FontImageSource

If you add a Size parameter

FontFamily={StaticResource FontAwesomeLight},
                            Size=16,
                             Color='White'}"

Then they all render correctly

Unfortunately, this workaround didn't work!

@PureWeen
Copy link
Contributor

@wagenheimer can you attach a repro?

I tested your sample by setting size and it worked for me

@PureWeen
Copy link
Contributor

The colors you have set for the fontimage is white which is really hard to see

<ShellContent
            Title="Items"
            ContentTemplate="{DataTemplate local:ItemsPage}"
            Icon="{FontImage Glyph={x:Static fontawesome:FontAwesomeIcons.List},
                             FontFamily={StaticResource FontAwesomeLight} ,
                                Size=16,
                             Color='Black'}" />



        <ShellContent
            Title="About"
            ContentTemplate="{DataTemplate local:AboutPage}"
            Icon="{FontImage Glyph={x:Static fontawesome:FontAwesomeIcons.CalendarAlt},
                             FontFamily={StaticResource FontAwesomeLight},
                                Size=16,
                             Color='Black'}" />

image

@samhouts samhouts added this to To do in Sprint 166 Feb 11, 2020
@samhouts samhouts moved this from To do to Continued in next sprint in Sprint 165 Feb 11, 2020
Shell automation moved this from Backlog to Done Feb 12, 2020
Sprint 166 automation moved this from To do to Done Feb 12, 2020
@samhouts samhouts added this to In Progress in v4.5.0 Feb 13, 2020
@samhouts samhouts moved this from In Progress to Done in v4.5.0 Feb 13, 2020
@samhouts samhouts removed this from Done in v4.5.0 May 6, 2020
@samhouts samhouts removed this from Done in Shell May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Sprint 165
  
Continued in next sprint
Sprint 166
  
Done
Development

No branches or pull requests

4 participants