Skip to content Skip to sidebar Skip to footer

Mirrored Text In Textview?

Im trying to do an application that simply outputs a bunch of text to the android screen, the problem is is that it has to be mirrored (Will be viewed as a 'hud'). Surprisingly, in

Solution 1:

Im pretty sure it is not possible with the pre-4.0 TextView.

A mirrored custom TextView is not that hard:

package your.pkg;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.TextView;

public class MirroredTextView extends TextView {

    public MirroredTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.translate(getWidth(), 0);
        canvas.scale(-1, 1);
        super.onDraw(canvas);
    }

}

And use as:

<your.pkg.MirroredTextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World" />

Post a Comment for "Mirrored Text In Textview?"