[程式] Android文字顯示(Opengl ES)
想在Adroid上用程式顯示文字
主要是用產生Bitmap
然後當作材質
最後畫出
但產生材質時
我丟入材質的大小(width、height,單位為px)
但圖檔的文字大小沒有剛好為材質的大小(文字沒貼滿材質,文字小很多)
是要怎麼設定?(layout內不是用px?要設定文字大小?layout的意義是什麼?)
我產生Bitmap的code如下:
Button b = new Button(context);
b.setText(str);
b.setBackgroundColor(0);
b.setDrawingCacheEnabled(true);
b.layout(0, 0, width, height);
~~~~~ ~~~~~~
b.buildDrawingCache();
this.bitmap = Bitmap.createBitmap(b.getDrawingCache());
b.setDrawingCacheEnabled(false);
我之前在C++上是用FreeType
在java上可以直接用嗎?(不用NDK的方式,直接import)
或者android有更好更直接的方法???
請大家解惑謝謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.163.12.151
※ 文章網址: http://www.ptt.cc/bbs/GameDesign/M.1397648550.A.BC1.html
→
04/16 20:07, , 1F
04/16 20:07, 1F
→
04/16 20:08, , 2F
04/16 20:08, 2F
→
04/16 20:10, , 3F
04/16 20:10, 3F