从View位图在Android上不显示 [英] Bitmap from View not displayed on Android

查看:110
本文介绍了从View位图在Android上不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建未显示任何内容将其设置为与OpenGL在Android的纹理视图的位图。 现在的问题是,当我创建位图的我的看法布局参数有值为0的事业onLayout()函数没有被调用呢。 有没有一种方法来模拟的布局还是做一个背景布置,以获得正确的布局PARAMS? 我在想有两个视图的框架布局,后台一会被用来创建我的位图的布局将已经完成。

I am trying to create a bitmap from a View that is not displayed yet to set it as a texture with OpenGL in android. The problem is that when I create my bitmap the layout parameters of my View have 0 value cause the onLayout() function has not been called yet. Is there a way to "simulate" a layout or do a "background layout" to get the right layout params ? I was thinking about a Frame layout having two views, the background one would be used to create my bitmap as the layout would have been done.

感谢。

推荐答案

您确实需要绘制成位图前布局的视图。简单地调用myView.measure(...),那么myView.layout(0,0,myView.getMeasuredWidth(),myView.getMeasuredHeigh())。我已经张贴在如何做到这一点在以下presentations的一个例子:<一href="http://www.curious-creature.org/2010/12/02/android-graphics-animations-and-tips-tricks/">http://www.curious-creature.org/2010/12/02/android-graphics-animations-and-tips-tricks/

You indeed need to layout your View before drawing it into a Bitmap. Simply call myView.measure(...) then myView.layout(0, 0, myView.getMeasuredWidth(), myView.getMeasuredHeigh()). I have posted an example on how to do this in one of the following presentations: http://www.curious-creature.org/2010/12/02/android-graphics-animations-and-tips-tricks/

这篇关于从View位图在Android上不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆