添加文本视图表面观 [英] Adding text view to surface view

查看:192
本文介绍了添加文本视图表面观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个一个表面鉴于我的应用程序,现在我想文本视图添加到此编程。我怎样才能做到这一点。

i use this a s surface view in my application and now i want to add text view to this programmatically. How can i do that.

"<com.csfcse.udrawer.UdrawerDrawingSurface
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent"
  android:id="@+id/drawingSurface" 
        android:layout_gravity="left" />"

谢谢......

Thanks......

推荐答案

这是选择可能是有一个的FrameLayout有两个孩子,第一个SurfaceView,那么不管你想要覆盖的SurfaceView。在下面的示例中,的FrameLayout第二种观点是有一个按钮和一个TextView一个horozontil的LinearLayout。该的FrameLayout显示其作为所有在底部堆在Z序的第一个孩子,并定位在左上角的所有儿童。在这种情况下的LinearLayout有Gravity.CENTER_VERTICAL(我想你可以做同样的事情上的LinearLayout填充。

An option may be to have a FrameLayout with two children, first the SurfaceView, then whatever you want to overlay on the SurfaceView. In the sample below, the second View in the FrameLayout is a horozontil LinearLayout with a Button and a TextView. The FrameLayout displays all its children as piled in Z order with the first child at the bottom and all children positioned at the upper left corner. In this case the LinearLayout has Gravity.CENTER_VERTICAL (I think you could do the same thing with padding on the LinearLayout.

我从来没有发现有关如何SurfaceViews多少(好)的文件(或任何屏幕绘图)的作品。可能有闪烁或刷新的一个问题,但我没有看到我的Froyo埃沃太大的问题。 (此测试应用程序借鉴了按钮下面的SurfaceView和TextView的捻转行。

I have never found much (good) documentation about how SurfaceViews (or any of the screen drawing) works. There may be a problem with flickering or refresh, but I don't see much problem on my Froyo Evo. (This test app draws 'twirling' lines on the SurfaceView below the Button and TextView.

如果问题很简单:你如何编程一个TextView添加到是由XML创建的布局充气布局的话,得到的布局实例的引用,并调用addView()把它

If the question is simply: How do you programmatically add a TextView to a Layout that was created by a XML inflated Layout, then, get a reference to the Layout instance and call addView() to it.

Layout lay = parentLayo.findViewById(R.id.drawingSurfaceParent);
TextView tv = new TextView(this);
tv.setText("New textview");
lay.addView(tv);

这篇关于添加文本视图表面观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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