我正在开发一个我已经集成的应用程序Google map API v2
。有一个滑动菜单,我在运行时使用HorizontalScrollView
. 问题是我只能垂直滚动地图,因为我尝试水平滚动HorizontalScrollView
获取触摸事件。
这就是我制作布局的方式。
LayoutInflater inflater = LayoutInflater.from(this);
View menu = inflater.inflate(R.layout.menu, null);
HorizontalScrollView hsv = new HorizontalScrollView(this) {
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (Menu_Displayed) {
return false;
} else {
return true;
}
}
LinearLayout li_body = new LinearLayout(this);
li_body.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT));
li_body.setOrientation(0);
li_body.setBackgroundColor(Color.TRANSPARENT);
hsv.addView(li_body);
TextView placeholder = new TextView(this);
placeholder.setTextColor(Color.TRANSPARENT);
placeholder.setLayoutParams(new LayoutParams(width - 130,
LayoutParams.MATCH_PARENT));
placeholder.setVisibility(View.INVISIBLE);
li_body.addView(placeholder);
LayoutInflater inflatex = LayoutInflater.from(this);
View mainScreen = inflatex.inflate(R.layout.main, null);
li_body.addView(mainScreen);
FrameLayout mainFrame = new FrameLayout(this);
mainFrame.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
mainFrame.addView(menu);
mainFrame.addView(hsv);
hsv.post(new Runnable() {
@Override
public void run() {
hsv.scrollBy(width - 130, 0);
}
});
setContentView(mainFrame);
有View
mainScreen
一个地图片段。有什么解决方案可以让我滚动地图horizontally
吗?