Skip to content

Instantly share code, notes, and snippets.

@amatkivskiy
Created July 6, 2015 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amatkivskiy/ae9a89dc5bd974c75e65 to your computer and use it in GitHub Desktop.
Save amatkivskiy/ae9a89dc5bd974c75e65 to your computer and use it in GitHub Desktop.
Example of Material Drawer with CustomView.
namespace Sample
{
using Android.App;
using Android.OS;
using Android.Widget;
using Mikepenz.MaterialDrawer;
using Android.Support.V7.App;
[Activity(MainLauncher = true, Label = "TestCustomDrawerViewActivity", Theme = "@style/MaterialDrawerTheme.Light.DarkToolbar.TranslucentStatus")]
public class TestCustomDrawerViewActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_sample_dark_toolbar);
var toolbar = this.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
this.SetSupportActionBar(toolbar);
var layout = new LinearLayout(this);
layout.Orientation = Orientation.Vertical;
var image = new ImageView(this);
image.SetScaleType(ImageView.ScaleType.CenterInside);
image.SetImageResource(Resource.Drawable.header);
var textView = new TextView(this);
textView.Text = "Custom Text";
textView.Gravity = Android.Views.GravityFlags.CenterHorizontal;
layout.AddView(image);
layout.AddView(textView);
var result = new DrawerBuilder()
.WithActivity(this)
.WithToolbar(toolbar)
.WithCustomView(layout)
.WithSavedInstance(savedInstanceState)
.Build();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment