使用 ViewGroup.addView() 将 GestureOverlayView 添加到 SurfaceView 游戏面板
经过这里好心人的大力帮助,我终于几乎让我的小游戏面板(这是一个 SurfaceView 类)启动并使用 GestureOverlayView 运行。通过使用 addView,我终于能够添加 GestureOverlayView 并使其正常工作,问题是调用此方法:
/** create the login form */
private ViewGroup _createGameStuffs() {
GestureOverlayView gestures = new GestureOverlayView(this);
gestures.setOrientation(gestures.ORIENTATION_VERTICAL);
gestures.setEventsInterceptionEnabled(true);
gestures.setGestureStrokeType(gestures.GESTURE_STROKE_TYPE_MULTIPLE);
gestures.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
//GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
Panel p = new Panel(this); //my game view
panel.addView(p,0); //add it to the group
panel.addView(gestures,1); //add the gestureoverlayview i made to the group
return panel;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
mLibrary = GestureLibraries.fromRawResource(this, R.raw.myspells);
// create the panel to enclose everything
View mainPanel = _createGameStuffs();
// show the panel on the screen
setContentView(mainPanel);
//setContentView(p);
}
根据我给出的索引,哪个视图占据主导地位。这让我相信我的游戏面板必须作为子视图添加到 GestureOverlayView,这是正确的吗?如果是这样,我如何获取 GestureOverlayView 的子视图?或者是相反,GestureOverlayView 成为我的主视图的子视图?
After much help from the good people here, I finally almost got my little game panel (thats a surfaceview class) up and running with a GestureOverlayView. Through the use of addView I finally was able to add the GestureOverlayView and get it to work, the trouble is that calling this:
/** create the login form */
private ViewGroup _createGameStuffs() {
GestureOverlayView gestures = new GestureOverlayView(this);
gestures.setOrientation(gestures.ORIENTATION_VERTICAL);
gestures.setEventsInterceptionEnabled(true);
gestures.setGestureStrokeType(gestures.GESTURE_STROKE_TYPE_MULTIPLE);
gestures.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
//GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
Panel p = new Panel(this); //my game view
panel.addView(p,0); //add it to the group
panel.addView(gestures,1); //add the gestureoverlayview i made to the group
return panel;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
mLibrary = GestureLibraries.fromRawResource(this, R.raw.myspells);
// create the panel to enclose everything
View mainPanel = _createGameStuffs();
// show the panel on the screen
setContentView(mainPanel);
//setContentView(p);
}
Depending upon which index I give which view takes presedence. This leads me to believe my game panel has to be added as a child view to the GestureOverlayView, is this correct? If so, how do I get at the children views of the GestureOverlayView? Or is it the other way around, GestureOverlayView becomes a child of my main view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论