How can I pinch to zoom (smoothly) and scroll around my entire activity screen? I've found dozens of post that talk about pinch to zoom for an ImageView but thats not what I'm trying to do. In my activity I have an image, text, and buttons. I want them all to scale evenly when the user pinches to zoom or scrolls.
In my xml layout I'm using a relative layout if that matters. Currently I found a function to zoom in and out of the entire activity (on tap only) but its not smooth and doesn't allow me to scroll around the screen. Is there a way of adding to my current code or is there another way of doing this? Thanks
Heres my current code in my .java:
public class MapActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
View view =getLayoutInflater().inflate(R.layout.activity_map,null);
setContentView(view);
view.setOnClickListener(new View.OnClickListener() {
float zoomFactor = 1.3f;
boolean zoomedOut = false;
@Override
public void onClick(View v) {
if(zoomedOut) {
v.setScaleX(1);
v.setScaleY(1);
zoomedOut = false;
}
else {
v.setScaleX(zoomFactor);
v.setScaleY(zoomFactor);
zoomedOut = true;
}
}
});
Any help would be appreciated. Thanks
Solved: @MoQ gave me an easy library solution using GestureFrameLayout from this library!