I want to do pinching functionality (zoom in /zoom Out) for text view .
I have already refer to many tutorials but not getting any fruitful ..please help me if any one have done it or Knows how to do it ....
Can I do it also with using button as zoom in and out and/or using 2 finger pinching ?
any help would be appreciated.. thanks
not working code:
setContentView(R.layout.main);
mainView =(LinearLayout)findViewById(R.id.linearLayout);
Button buttonZoomOut = (Button)findViewById(R.id.buttonZoomOut);
Button buttonNormal = (Button)findViewById(R.id.buttonNormal);
Button buttonZoomIn = (Button)findViewById(R.id.buttonZoomIn);
buttonZoomOut.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
zoom(0.5f,0.5f,new PointF(0,0));
}
});
buttonNormal.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
zoom(1f,1f,new PointF(0,0));
}
});
buttonZoomIn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
zoom(2f,2f,new PointF(0,0));
}
});
}
/** zooming is done from here */
public void zoom(Float scaleX,Float scaleY,PointF pivot){
mainView.setPivotX(pivot.x);
mainView.setPivotY(pivot.y);
mainView.setScaleX(scaleX);
mainView.setScaleY(scaleY);
}
If you want to implement finger pinch, you can see this sample code given by Google developer blog.
I tried it before. It works and good for learning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With