开发者

Floating Buttons over a screen filling view?

I´m having a problem with my Android Project.

I have a screen filling custom View, which displays a canvas. The canvas consists of a background picture and another picture layer, in which can be finger drawn. Additionally, the canvas view can be dragged and pinch-zoomed. Now I implemented a detection for 'longClicks', i.e. finger down on same region for 1 second. As a result of this gesture, a small menu should pop up over the pointed region. The menu itself should consist of something like a TabHost/TabWidget, i.e. smaller icons on riders on top which reveal separate EditText, Buttons etc. at the lower part of the menu.

Now the question is: How can it technically be done?

1) I played around with TabHost etc., but I think it´s only possible to use when having a TabActivity. Is this correct?

2) Then I searched for a possibility to overlay my main activity with this TabActivity, resulting in that it´s possible, but I couldn´t really control where the overlay Activity was placed, it always started on top left. Is there a possibility to place an Activity somewhere on the screen?

3) Next I discarded my idea with the tabbed menu and searched for a possibility to only overlay my view with another view (and have the possibility to remove it later again). I read, that it´s possible with the ViewManager. But how do I access the ViewManager? Documentation says: http://developer.android.com/reference/android/view/ViewManager.html

call Context.getSystemService().

but via this function, I can only get the WindowManager and not the ViewManager. wtf?

I´m really stuck right now...can somebody give me a hand here?

edit: I managed the view over view problem by programmatically instanciating a Layout and then handing it in as contentView.

rl = new RelativeLayout(getBaseContext());
 rl.addView(cview);
 cview.setId(1111);
 View overlay = getLayoutInflater().inflate(R.layout.menuoverlay, rl, false);
 LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
 lp.addRule(RelativeLayout.ALIGN_LEFT, cview.getId());
 lp.addRule(RelativeLayou开发者_JS百科t.CENTER_VERTICAL, cview.getId());
 rl.addView(overlay, lp);

Now when making the Layout static and by writing some getter/setter methods, I'm now able to control adding and removing of views.

private static rl;
//scroll scroll
 public static void addView(View view){
 rl.addView(view);

}


1) I played around with TabHost etc., but I think it´s only possible to use when having a TabActivity. Is this correct?

No. For an example of using TabHost without a TabActivity, take a look at Is it realizable on Android?


I finally used PopupWindow now. http://developer.android.com/reference/android/widget/PopupWindow.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜