作者newJoey (newJoey)
看板GameDesign
标题[程式] Android文字显示(Opengl ES)
时间Wed Apr 16 19:42:27 2014
想在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://webptt.com/cn.aspx?n=bbs/GameDesign/M.1397648550.A.BC1.html
1F:→ azureblaze:layout是按钮的大小 文字大小要用setTextSize 04/16 20:07
2F:→ azureblaze:可是你不觉得拿按钮来制作文字材质很奇怪吗? 04/16 20:08