TextView, ListView bottom border using xamarin cross platform for Android

SanjayTejaniSanjayTejani USMember ✭✭✭
edited January 2016 in Cross Platform with Xamarin

---- TextView Rednder ----

using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using xamfor.Droid;
using Android.Graphics.Drawables;

[assembly: ExportRenderer(typeof(TableView), typeof(CustomTableViewRender))]
namespace xamfor.Droid
{
class CustomTableViewRender : TableViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (Control == null)
return;

        var tableView = Control as Android.Widget.ListView;
        tableView.Divider = new ColorDrawable(Android.Graphics.Color.Gray);
        tableView.DividerHeight = 1;
    }
}

}

---- ListView Rednder ----

using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using xamfor.Droid;
using Android.Graphics.Drawables;

[assembly: ExportRenderer(typeof(ListView), typeof(CustomViewCellRenderer))]
namespace xamfor.Droid
{
public class CustomViewCellRenderer : ListViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (Control == null)
return;

        var tableView = Control as Android.Widget.ListView;
        tableView.Divider = new ColorDrawable(Android.Graphics.Color.Gray);
        tableView.DividerHeight = 1;
    }
}

}

Tagged:

Answers

  • SanjayTejaniSanjayTejani USMember ✭✭✭
    edited January 2016

    This code is working for Xamarin cross platform for Android.

Sign In or Register to comment.