Rounded Corner Picker Bug

johnstrimjohnstrim USMember ✭✭
edited October 26 in Xamarin.Forms

Hey everyone. So I'm trying to create a rounded corner Picker on Xamarin Forms. Here is a solution that works for anyone who wants to try it:

PCL Project:

        public class RoundedPicker : Picker
        {
        }

Android Project:
C# Export Renderer Class:

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

               if (Control != null)
               {
                    this.Control.SetBackgroundResource(Resource.Drawable.RoundedEntry);
               }
          }

XML Resource.Drawable.RoundedEntry file:

        <selector xmlns:android="http://schemas.android.com/apk/res/android">
          <item android:state_focused="true" >
            <shape android:shape="rectangle">
              <gradient
                  android:startColor="#FFFFFF"
                  android:endColor="#FFFFFF"
                  android:angle="270" />
              <stroke
                  android:width="1dp"
                  android:color="@color/entry_border" />
              <corners
                  android:radius="6dp" />
            </shape>
          </item>
          <item>
            <shape android:shape="rectangle">
              <gradient
                  android:startColor="#FFFFFF"
                  android:endColor="#FFFFFF"
                  android:angle="270" />
              <stroke
                  android:width="1dp"
                  android:color="#FFFFFF" />
              <corners
                  android:radius="6dp" />
            </shape>
          </item>
        </selector>

Best Answer

  • johnstrimjohnstrim USMember ✭✭
    edited October 26 Accepted Answer

    I had added it as an error before but I changed it. It works perfectly!

Answers

  • johnstrimjohnstrim USMember ✭✭
    edited October 26 Accepted Answer

    I had added it as an error before but I changed it. It works perfectly!

Sign In or Register to comment.