locked
Frame looks bad on Android Lollipop RRS feed

  • Question

  • User369433 posted

    Hello. I have a simple view with Frame control. On Android above Lollipop it looks like that:

    which is fine

    but on Android 5.0 (Lollipop) it looks like that:

    which looks bad.

    How to have the same appearance of Frame on both on Lollipop devices and others?

    Thank you in advance for all the help :smile:

    Tuesday, December 11, 2018 9:53 AM

All replies

  • User359363 posted

    @Mikilll , please post your code.

    Wednesday, December 12, 2018 5:09 AM
  • User369433 posted

    @YorkGo Just put the Frame control inside the view and compare its appearance between Android Lollipop and higher. I think this issue is very easy to reproduce.

    Wednesday, December 12, 2018 8:19 AM
  • User369433 posted

    @YorkGo Are you kidding me?

    First - I am using Xamarin.Forms, not Xamarin.Android Second - I have clearly written that problem exists only on Android Lollipop. On higher Android versions the Frame looks fine.

    Thursday, December 13, 2018 8:32 AM
  • User359363 posted

    @Mikilll , sorry for my misunderstanding, I could reproduce this issue now, will spend some time troubleshooting about this issue.

    Thursday, December 13, 2018 12:22 PM
  • User359363 posted

    @Mikilll ,

    Here is a workaround, you need to create your shadow under Drawable folder of Android resources. For example:

    <?xml version="1.0" encoding="utf-8" ?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
      <item>
        <shape android:shape="rectangle">
          <solid android:color="#CABBBBBB" />
          <corners android:radius="2dp" />
        </shape>
      </item>
    
      <item
          android:left="0dp"
          android:right="0dp"
          android:top="0dp"
          android:bottom="2dp">
        <shape android:shape="rectangle">
          <solid android:color="@android:color/white" />
          <corners android:radius="2dp" />
        </shape>
      </item>
    </layer-list>
    

    Name this file as "shadow.xml" and place it under the Drawable folder of Android project, then in your RatingInfoFrameRenderer:

    public class RatingInfoFrameRenderer : FrameRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
        {
            base.OnElementChanged(e);
            if (e.NewElement != null)
            {
                this.SetBackgroundResource(Resource.Drawable.shadow);
            }
        }
    }
    

    To change the style of shadow, you can modify the shadow.xml file, for more information about this, you may refer to google's official document: LayerList.

    Thursday, December 13, 2018 3:48 PM