0

Androidでtextviewの鏡像を作成しようとしています。以下のコードを試しましたが、うまくいきません

私のコードは以下の通りです: -

public class MainActivity extends Activity {
TextView tv;
ImageView myImageView;
Bitmap bmp;
int bmpWidth, bmpHeight;

Matrix matrixMirrorY;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv=(TextView)findViewById(R.id.tv1);

        tv.buildDrawingCache();
        bmp=Bitmap.createBitmap(tv.getDrawingCache());

        Matrix matrix = new Matrix(); 
        matrix.preScale(-1.0f, 1.0f); 
        Bitmap mirroredBitmap = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, false);
        myImageView.setImageBitmap(mirroredBitmap);          
            }       

    }
4

1 に答える 1