Android : Views messing up when adding views into ZoomView in android

on Tuesday, July 29, 2014


In my android app, I have a linearlayout and I add lots of stuff into it. It will go past the screen border horizontally and vertically. I want the user to be able to pinch zoom and pan around. I am using the plugin zoomview from here https://code.google.com/p/android-zoom-view/downloads/list


This is my code:


layout is the layout I create and use to add content. It is the one I want to zoom and pan in. So what I do is, make that view, then put it in a scrollview, then put that scrollview, in the zoomview, then put the zoomview in a top level linear layout.


The problem is, when I see on the phone, it will not allow me to move downwards. I can zoom in and out and pan around horizontally only, but there is weird flashes of different screens and its not working properly...


Does anyone know how to fix it?


Thanks



public LinearLayout createZoom() {

LinearLayout layout = new LinearLayout(this);
ScrollView.LayoutParams layoutmargin = new ScrollView.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ScrollView.LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(layoutmargin);
layout.setOrientation(LinearLayout.VERTICAL);

ScrollView scroll = new ScrollView(this);
ZoomView.LayoutParams scrollmargin = new ZoomView.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ZoomView.LayoutParams.MATCH_PARENT);
scroll.setLayoutParams(scrollmargin);
scroll.addView(layout);

ZoomView zoomView = new ZoomView(this);
LinearLayout.LayoutParams zoommargin = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
zoomView.setLayoutParams(zoommargin);
zoomView.addView(scroll);

LinearLayout top_container = (LinearLayout) findViewById(R.id.top_container);
top_container.addView(zoomView);

return layout;
}

0 comments:

Post a Comment