本文整理汇总了C#中Android.Graphics.Paint.Ascent方法的典型用法代码示例。如果您正苦于以下问题:C# Paint.Ascent方法的具体用法?C# Paint.Ascent怎么用?C# Paint.Ascent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Paint
的用法示例。
在下文中一共展示了Paint.Ascent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AndroidFontMetrics
public AndroidFontMetrics(Paint paint)
{
_widths = new float[NumWidths];
paint.GetTextWidths (_chars, 0, NumWidths, _widths);
Ascent = (int)(Math.Abs (paint.Ascent ()) + 0.5f);
Descent = (int)(paint.Descent ()/2 + 0.5f);
Height = Ascent;
}
示例2: CreateBitmapData
void CreateBitmapData (string str, out byte[] bitmapData, out int width, out int height)
{
Paint paint = new Paint ();
paint.TextSize = 128;
paint.TextAlign = Paint.Align.Left;
paint.SetTypeface (Typeface.Default);
width = height = 256;
float textWidth = paint.MeasureText (str);
using (Bitmap bitmap = Bitmap.CreateBitmap (width, height, Bitmap.Config.Argb8888)) {
Canvas canvas = new Canvas (bitmap);
paint.Color = str != " " ? Color.White : Color.LightGray;
canvas.DrawRect (new Rect (0, 0, width, height), paint);
paint.Color = Color.Black;
canvas.DrawText (str, (256 - textWidth) / 2f, (256 - paint.Descent () - paint.Ascent ()) / 2f, paint);
bitmapData = new byte [width * height * 4];
Java.Nio.ByteBuffer buffer = Java.Nio.ByteBuffer.Allocate (bitmapData.Length);
bitmap.CopyPixelsToBuffer (buffer);
buffer.Rewind ();
buffer.Get (bitmapData, 0, bitmapData.Length);
}
}
示例3: CalcBounds
private Rect CalcBounds(int index, Paint paint)
{
var bounds = new Rect();
var title = GetTitle(index);
bounds.Right = (int)paint.MeasureText(title);
bounds.Bottom = (int)(paint.Descent() - paint.Ascent());
return bounds;
}
示例4: CalcBounds
/**
* Calculate the bounds for a view's title
*
* @param index
* @param paint
* @return
*/
private RectF CalcBounds(int index, Paint paint)
{
//Calculate the text bounds
RectF bounds = new RectF();
bounds.Right = paint.MeasureText(mTitleProvider.GetTitle(index));
bounds.Bottom = paint.Descent() - paint.Ascent();
return bounds;
}
示例5: calcBounds
/**
* Calculate the bounds for a view's title
*
* @param index
* @param paint
* @return
*/
private Rect calcBounds(int index, Paint paint)
{
//Calculate the text bounds
Rect bounds = new Rect();
string title = getTitle(index);
bounds.Right = (int)paint.MeasureText(title, 0, title.Length);
bounds.Bottom = (int)(paint.Descent() - paint.Ascent());
return bounds;
}