0
(注意,我是Android编程的初学者)在自定义GLSurfaceView上添加视图
我有一个派生自GLSurfaceView的类。
我想要的是放置一些意见(图像,文字)。 我设法通过使用textView.setPadding(300,0,0,0)
来正确定位文本视图;
问题是我无法正确定位图像视图。我试过imageView.layout(), imageView.setPadding()
。
下面是代码:
ImageView imageView=new .... // Create and set drawable
// Setting size works as expected
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(200,200);
imageView.setLayoutParams(lp);
surfaceView = new MySurfaceViewDerivedFromOpenGLSurface(...);
setContentView(surfaceView);
addContentView(textView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
addContentView(textView2, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
addContentView(imageView, lp); // Add the image view
它甚至有可能将其正确的使用方法,而不在XML文件中specifing填充位置?
我在sdk dev网站上看到了一个例子,展示了如何在openGL表面视图上创建视图,但问题是我有一个派生类,我不知道我是否可以在XML文件中指定它(我在XML中有0%的经验,到目前为止,Eclipse为我处理所有事情)。
不错,非常感谢:D – n3XusSLO