Я использовал метод SetHeight в конце переопределенного метода OnDraw для решения проблемы:
> protected override void OnDraw(Canvas canvas)
> {
> float floatCharSpaceSize;
> float floatWordWidth;
> float floatEmptySpace;
> float floatJustifedSpaceSize;
> float floatLineWidth;
> float floatTextAreaWidth;
> float floatWordPositionX;
> float floatWordPositionY;
> int intLineEnd;
> int intLineStart;
> int intSpaceCount;
> int intTextHeight;
> int intRemaindedSpaceSize;
> Layout layoutTextView;
> Paint.FontMetrics fontMetrics_Paint;
> string stringLine;
> string stringText;
> string[] stringArrWord;
> TextPaint textPaint = Paint;
>
> textPaint.Color = new Color(CurrentTextColor);
> textPaint.DrawableState = GetDrawableState();
> floatTextAreaWidth = MeasuredWidth - (PaddingLeft + PaddingRight);
> floatCharSpaceSize = textPaint.MeasureText(" ");
> stringText = Text;
> floatWordPositionY = TextSize + PaddingTop;
> layoutTextView = Layout;
>
> if (layoutTextView == null)
> {
> return;
> }
>
> fontMetrics_Paint = textPaint.GetFontMetrics();
> intTextHeight = (int)(Math.Ceiling(fontMetrics_Paint.Bottom - fontMetrics_Paint.Top) *
> LineSpacingMultiplier + layoutTextView.SpacingAdd);
>
> for (int intIndexA = 0; intIndexA < layoutTextView.LineCount; intIndexA++)
> {
> intLineStart = layoutTextView.GetLineStart(intIndexA);
> intLineEnd = layoutTextView.GetLineEnd(intIndexA);
> floatLineWidth = StaticLayout.GetDesiredWidth(Text, intLineStart, intLineEnd, textPaint);
> stringLine = Text.Substring(intLineStart, intLineEnd - intLineStart);
>
> if (stringLine[stringLine.Length - 1] == ' ')
> {
> stringLine = stringLine.Substring(0, stringLine.Length - 1);
> floatLineWidth -= floatCharSpaceSize;
> }
>
> if (BoolJustify == true && intIndexA < layoutTextView.LineCount - 1)
> {
> floatEmptySpace = floatTextAreaWidth - floatLineWidth;
> intSpaceCount = stringLine.Split(' ').Length - 1;
> floatJustifedSpaceSize = (int)(floatEmptySpace / intSpaceCount) + floatCharSpaceSize;
> intRemaindedSpaceSize = (int)(((floatEmptySpace / intSpaceCount) - (int)(floatEmptySpace / intSpaceCount)) *
> intSpaceCount);
> stringArrWord = stringLine.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
>
> if (IntLangDirection == (int)ApplicationLSchool.LangDirection.LTR)
> {
> floatWordPositionX = 0;
>
> for (int intIndexB = 0; intIndexB < stringArrWord.Length; intIndexB++)
> {
> floatWordWidth = StaticLayout.GetDesiredWidth(stringArrWord[intIndexB], textPaint);
>
> canvas.DrawText(stringArrWord[intIndexB], floatWordPositionX, floatWordPositionY, textPaint);
>
> if (intRemaindedSpaceSize > 0)
> {
> floatWordPositionX += floatWordWidth + floatJustifedSpaceSize + 1;
>
> intRemaindedSpaceSize--;
> }
> else
> {
> floatWordPositionX += floatWordWidth + floatJustifedSpaceSize;
> }
> }
> }
> else if (IntLangDirection == (int)ApplicationLSchool.LangDirection.RTL)
> {
> floatWordPositionX = floatTextAreaWidth;
>
> for (int intIndexB = 0; intIndexB < stringArrWord.Length; intIndexB++)
> {
> floatWordWidth = StaticLayout.GetDesiredWidth(stringArrWord[intIndexB], textPaint);
>
> canvas.DrawText(stringArrWord[intIndexB], floatWordPositionX - floatWordWidth, floatWordPositionY, textPaint);
>
> if (intRemaindedSpaceSize > 0)
> {
> floatWordPositionX -= floatWordWidth + floatJustifedSpaceSize + 1;
>
> intRemaindedSpaceSize--;
> }
> else
> {
> floatWordPositionX -= floatWordWidth + floatJustifedSpaceSize;
> }
> }
> }
> }
> else
> {
> if (IntLangDirection == (int)ApplicationLSchool.LangDirection.LTR)
> {
> canvas.DrawText(stringLine, 0, floatWordPositionY, textPaint);
> }
> else if (IntLangDirection == (int)ApplicationLSchool.LangDirection.RTL)
> {
> canvas.DrawText(stringLine, floatTextAreaWidth - floatLineWidth, floatWordPositionY, textPaint);
> }
> }
>
> floatWordPositionY += intTextHeight;
> }
>
> **SetHeight((int)(floatWordPositionY - TextSize - layoutTextView.SpacingAdd) + PaddingBottom);**
> }