Java 画布垂直绘制文本

Java 画布垂直绘制文本,java,android,text,android-canvas,draw,Java,Android,Text,Android Canvas,Draw,我已经把所有我需要的东西都放在我想要的地方,我的位图、背景和所有东西,我需要的是画出垂直显示的文本。以下是我目前的代码: private void drawTables(Canvas canvas) { for (Table table : mTablesList) { float x = mWidht * table.getLeft() / 100; float y = mHeight * table.getTop() / 100; R

我已经把所有我需要的东西都放在我想要的地方,我的位图、背景和所有东西,我需要的是画出垂直显示的文本。以下是我目前的代码:

 private void drawTables(Canvas canvas) {
    for (Table table : mTablesList) {
        float x = mWidht * table.getLeft() / 100;
        float y = mHeight * table.getTop() / 100;
        Rect rect = new Rect();
        rect.set(Math.round(x), Math.round(y), mWidht * table.getRight() / 100, mHeight * table.getBottom() / 100);
        if (table.isAvaliable()) {
            Drawable myDrawable = getResources().getDrawable(R.drawable.slobodan);
            Bitmap myBitmap = ((BitmapDrawable) myDrawable).getBitmap();
            table.setRect(rect);
            Bitmap nova = getResizedBitmap(myBitmap, 60, 60);
            Rect source = new Rect(0, 0, nova.getWidth(), nova.getHeight());
            table.setSlikaRezervacije(nova);
            canvas.drawBitmap(nova, source, table.getRect(), null);
        } else if (!table.isAvaliable()) {
            Drawable myDrawable = getResources().getDrawable(R.drawable.rezervisan);
            Bitmap myBitmap = ((BitmapDrawable) myDrawable).getBitmap();
            table.setRect(rect);
            Bitmap nova = getResizedBitmap(myBitmap, 60, 60);
            Rect source = new Rect(0, 0, nova.getWidth(), nova.getHeight());
            table.setSlikaRezervacije(nova);
            canvas.drawBitmap(nova, source, table.getRect(), null);
        }

    }}
首先,你需要

然后,旋转画布

canvas.rotate(yourTextAngle, originX, originY);
然后,你画你的文本

canvas.drawText("Your text", originX, originY, paint);
文本应根据您提供的角度垂直绘制

然后,如果要在以下时间之后恢复画布:

canvas.restore();

你应该在上查看信息。非常彻底。

要显示的文本变量在哪里?你到底想把它放在哪里?只需垂直旋转文本就足够了,还是要将每个字符显示在彼此的顶部?请更具体地说,thx仅用于旋转文本。Canvas类具有可用于此目的的保存、旋转和还原方法。看看那些。
canvas.restore();