android在图片上任意位置添加文字,可以使用canvas类进行 *** 作,实例如下:
@Overrideprotected void onDraw(Canvas canvas)
{
super.onDraw(canvas)
canvas.drawBitmap(m_LogInBmp, null, m_LogIndst, m_txBackPaint)
float tleft = m_LogIndst.left + (m_LogIndst.right - m_LogIndst.left - FontWidth*m_TextLogIn.length())/2
float ttop = m_LogIndst.top + (m_LogIndst.bottom - m_LogIndst.top - FontHeight)/2 +FontHeight
canvas.drawText( m_TextLogIn, tleft, ttop, mLogInPaint)
}
canvas 中可以用 fillText() 绘出文字。例如:
<html><body>
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myCanvas")
var ctx = c.getContext("2d")
ctx.font = "20px Georgia"
ctx.fillText("Hello World!", 10, 50)
ctx.font = "30px Verdana"
var gradient = ctx.createLinearGradient(0, 0, c.width, 0)
gradient.addColorStop("0", "magenta")
gradient.addColorStop("0.5", "blue")
gradient.addColorStop("1.0", "red")
ctx.fillStyle = gradient
ctx.fillText("Big smile!", 10, 90)
</script>
<p><strong>Note:</strong>The canvas tag is not supported in Internet
Explorer 8 and earlier versions.</p>
</body>
</html>
====
如果想插入显示一个文件或网页,可以用 <iframe>, 而不是用 画布<canvas>,
例如:
<iframe src="这里写网页的URL"></iframe>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)