我已经从这里实现了径向菜单库:https://code.google.com/p/radial-menu-widget/downloads/list。
我使用FrameLayout中的菜单,我在其中显示带有地图的WebView。如果我单击标记,则会弹出径向菜单。我的问题是,不是整个显示器都能正确响应弹出菜单。
图片:http://sceada.bplaced.net/1.png
在右侧,红线标志着某些东西的边界,我真的不知道那可能是什么。如果我在红线外单击,则菜单不会弹出。如果我切换到横向,它会变得更糟。 图片: http:// sceada.bplaced.net/2.png
我可以达到的所有视图都具有正常值(如预期的)宽度和高度。那可能是什么样的元素?
06-01 18:27:37.295: D/JsInterface(8640): popup.getWidth(): 1196
06-01 18:27:37.295: D/JsInterface(8640): popup.getHeight(): 638
06-01 18:27:37.295: D/JsInterface(8640): popup.getTag(): null
06-01 18:27:37.299: D/JsInterface(8640): Landscape
06-01 18:27:37.299: D/JsInterface(8640): statusBarOffset: 130
06-01 18:27:37.299: D/JsInterface(8640): xPosition: 598
06-01 18:27:37.299: D/JsInterface(8640): yPosition: 319
06-01 18:27:37.299: D/JsInterface(8640): xSource: 609
06-01 18:27:37.299: D/JsInterface(8640): ySource: 272
06-01 18:27:37.299: D/JsInterface(8640): dm.heightPixels: 768
06-01 18:27:37.299: D/JsInterface(8640): dm.widthPixels: 1196
06-01 18:27:37.299: D/JsInterface(8640): webViewHolder.getMeasuredHeight(): 638
06-01 18:27:37.299: D/JsInterface(8640): webViewHolder.getMeasuredWidth(): 1196
06-01 18:27:37.299: D/JsInterface(8640): pieMenu.getHeight(): 638
06-01 18:27:37.299: D/JsInterface(8640): pieMenu.getWidth(): 1196
06-01 18:27:37.299: D/JsInterface(8640): mWebView.getHeight(): 638
06-01 18:27:37.299: D/JsInterface(8640): mWebView.getWidth(): 1196
06-01 18:27:37.304: D/JsInterface(8640): item.getWidth(): 1196
06-01 18:27:37.304: D/JsInterface(8640): item.getHeight(): 638
06-01 18:27:37.304: D/JsInterface(8640): item.getTag(): null
一些代码我如何创建饼图菜单:
private void createPieMenu() {
mMenuItems.clear();
pieMenu = new RadialMenuWidget(this);
menuEditItem = new RadialMenuItem("edit","Edit");
menuAttributeItem = new RadialMenuItem("attribute","Attribute");
menuCloseItem = new RadialMenuItem("close", null);
menuCloseItem.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuCloseItem.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
@Override
public void execute() {
pieMenu.dismiss();
}
});
mMenuItems.add(menuEditItem);
mMenuItems.add(menuAttributeItem);
pieMenu.setCenterCircle(menuCloseItem);
pieMenu.setAnimationSpeed(1000L);
//pieMenu.setSourceLocation(200, 200);
//pieMenu.setShowSourceLocation(true);
pieMenu.setIconSize(15, 30);
pieMenu.setTextSize(13);
pieMenu.setOutlineColor(Color.BLACK, 225);
pieMenu.setInnerRingColor(0x72B7E8, 180);
pieMenu.addMenuEntry(mMenuItems);
mJsInterface.setPieMenu(pieMenu);
}
public void showRadialMenu(){
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
webViewHolder.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
pieMenu.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
pieMenu.layout(0, 0, (int)webViewHolder.getMeasuredWidth(), (int)webViewHolder.getMeasuredHeight());
pieMenu.invalidate();
View popup = (View) pieMenu.getRootView();
if(popup != null){
if(Konstanten.D){
Log.d("JsInterface", "popup.getWidth(): " + popup.getWidth());
Log.d("JsInterface", "popup.getHeight(): " + popup.getHeight());
Log.d("JsInterface", "popup.getTag(): " + popup.getTag());
}
}
pieMenu.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
pieMenu.setAnimation(onOpenAnimation((int)webViewHolder.getMeasuredHeight()/2, (int)webViewHolder.getMeasuredWidth()/2, x, y));
pieMenu.show(webViewHolder, 0, 0);
int count = webViewHolder.getChildCount();
for(int i = 0; i < count; i++){
View item = (View) webViewHolder.getChildAt(i);
if(item != null){
if(Konstanten.D){
Log.d("JsInterface", "item.getWidth(): " + item.getWidth());
Log.d("JsInterface", "item.getHeight(): " + item.getHeight());
Log.d("JsInterface", "item.getTag(): " + item.getTag());
}
}
}
}
});
}
答案 0 :(得分:0)
好的,我想我找到了解决方法。我实现了自己的PopupWindow并为其分配了饼图菜单。
window = new PopupWindow(mContext);
window.setWidth((int)webViewHolder.getMeasuredWidth());
window.setHeight(webViewHolder.getMeasuredHeight()+statusBarOffset);
window.setTouchable(true);
window.setFocusable(true);
window.setOutsideTouchable(true);
window.setBackgroundDrawable(new BitmapDrawable());
window.setContentView(pieMenu);
window.showAtLocation(webViewHolder, 0, 0, 0);
我花了5个小时来解决这个问题。糟糕的是,无法从库中修改PopUpWindow。