There is a linearlayout ,and want to "addView(linearlayout)" at the end,now I want zoom the layout, how I should do ?
I have searched this similar question ,and got a solution ,it provided a jar,but it only can zoom the layout before I draw something on the layout that I added, and it has a problem is that it show two view every time,one is the orignal view,one is can be zoomed just as I said, this is the link,How I can fix ? Thanks
enter link description here
Try performing a scale animation on the layout?
Start by creating the following instance variables:
private float mScale = 1f;
private ScaleGestureDetector mScaleDetector;
Initiate your scale gesture detector, utilizing ScaleAnimation:
mScaleDetector = new ScaleGestureDetector(this, new ScaleGestureDetector.SimpleOnScaleGestureListener()
{
@Override
public boolean onScale(ScaleGestureDetector detector)
{
float scale = 1 - detector.getScaleFactor();
float prevScale = mScale;
mScale += scale;
if (mScale < 0.1f) // Minimum scale condition:
mScale = 0.1f;
if (mScale > 10f) // Maximum scale condition:
mScale = 10f;
ScaleAnimation scaleAnimation = new ScaleAnimation(1f / prevScale, 1f / mScale, 1f / prevScale, 1f / mScale, detector.getFocusX(), detector.getFocusY());
scaleAnimation.setDuration(0);
scaleAnimation.setFillAfter(true);
myContainer.startAnimation(scaleAnimation);
return true;
}
});
Finally, override your onTouch method inside your activity to wire it up to your scale detector:
@Override
public boolean onTouchEvent(MotionEvent event)
{
mScaleDetector.onTouchEvent(event);
return super.onTouchEvent(event);
}
You'll probably need to tweak it a bit more to get the exact solution you want, but this should help get you started :)
Hope this helps :)