Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rotated textview for Xamarin Android
using Android.Content;
using Android.Widget;
using Android.Util;
using Android.Graphics;
namespace Droid
{
public class RotatedTextView : TextView
{
public RotatedTextView(Context ctx, IAttributeSet attr)
: base(ctx, attr)
{
}
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
base.OnMeasure(heightMeasureSpec, widthMeasureSpec);
SetMeasuredDimension(MeasuredHeight, MeasuredWidth);
}
protected override bool SetFrame(int left, int top, int right, int bottom)
{
return base.SetFrame(left, top, left + (bottom - top), top + (right - left));
}
protected override void OnDraw(Canvas canvas)
{
canvas.Translate(0, Width);
canvas.Rotate(-90);
canvas.ClipRect(0, 0, Width, Height, Region.Op.Replace);
base.OnDraw(canvas);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.