예제 #1
0
        public static VerticalAlign ToEtoVertical(this av.GravityFlags gravity)
        {
            switch (gravity & av.GravityFlags.VerticalGravityMask)
            {
            case av.GravityFlags.CenterVertical:
                return(VerticalAlign.Middle);

            case av.GravityFlags.Top:
                return(VerticalAlign.Top);

            case av.GravityFlags.Bottom:
                return(VerticalAlign.Bottom);

            default:
                throw new NotSupportedException();
            }
        }
예제 #2
0
        public static TextAlignment ToEtoHorizontal(this av.GravityFlags gravity)
        {
            switch (gravity & av.GravityFlags.HorizontalGravityMask)
            {
            case av.GravityFlags.CenterHorizontal:
                return(TextAlignment.Center);

            case av.GravityFlags.Left:
                return(TextAlignment.Left);

            case av.GravityFlags.Right:
                return(TextAlignment.Right);

            default:
                throw new NotSupportedException();
            }
        }
        public override void Paint(RelativeLayout Parent, Context Context, Single ps = 1)
        {
            if (this.View == null)
            {
                this.View = new BorderedTextView(Context);
                Parent.AddView(View);
            }

            base.Paint(Parent, Context, ps);

            BorderedTextView textView = (BorderedTextView)View;

            textView.Text = Text;
            textView.SetHeight((int)(Size.Height * ps));
            textView.SetWidth((int)(Size.Width * ps));
            textView.SetX((int)(Location.X * ps));
            textView.SetY((int)(Location.Y * ps));

            string[] Font = this.Font.Split(',');

            float fontSize = float.Parse(Font[1].Replace("pt", "").Trim());

            textView.SetTextSize(Android.Util.ComplexUnitType.Sp, fontSize);
            textView.SetTextColor(Android.Graphics.Color.ParseColor(ForeColor));

            Android.Views.GravityFlags alignment = Android.Views.GravityFlags.NoGravity;

            switch (Alignment)
            {
            case "Near":
                alignment = Android.Views.GravityFlags.Left;
                break;

            case "Center":
                alignment = Android.Views.GravityFlags.CenterHorizontal;
                break;

            case "Far":
                alignment = Android.Views.GravityFlags.Right;
                break;
            }

            switch (LineAlignment)
            {
            case "Near":
                alignment |= Android.Views.GravityFlags.Top;
                break;

            case "Center":
                alignment |= Android.Views.GravityFlags.CenterVertical;
                break;

            case "Far":
                alignment |= Android.Views.GravityFlags.Bottom;
                break;
            }

            textView.Gravity = alignment;

            if (BackColor != "Transparent")
            {
                GradientDrawable shape = new GradientDrawable();
                shape.SetShape(ShapeType.Rectangle);
                shape.SetColor(Android.Graphics.Color.ParseColor(BackColor));
                textView.Background = shape;
            }

            textView.Borders = Borders;
            textView.SetPadding(Padding.Left, Padding.Top, Padding.Right, Padding.Bottom);
        }