* Don't allow the image to be panned off screen. As much of the image as possible is always displayed, centered in the view when it is smaller. This is the best option for galleries.
*/
/** Don't allow the image to be panned off screen. As much of the image as possible is always displayed, centered in the view when it is smaller. This is the best option for galleries. */
publicstaticfinalintPAN_LIMIT_INSIDE=1;
publicstaticfinalintPAN_LIMIT_INSIDE=1;
/** Allows the image to be panned until it is just off screen, but no further. The edge of the image will stop when it is flush with the screen edge. */
/**
* Allows the image to be panned until it is just off screen, but no further. The edge of the image will stop when it is flush with the screen edge.
*/
publicstaticfinalintPAN_LIMIT_OUTSIDE=2;
publicstaticfinalintPAN_LIMIT_OUTSIDE=2;
/** Allows the image to be panned until a corner reaches the center of the screen but no further. Useful when you want to pan any spot on the image to the exact center of the screen. */
/**
* Allows the image to be panned until a corner reaches the center of the screen but no further. Useful when you want to pan any spot on the image to the exact center of the screen.
@@ -850,7 +837,8 @@ public class SubsamplingScaleImageView extends View {
...
@@ -850,7 +837,8 @@ public class SubsamplingScaleImageView extends View {
* Adjusts hypothetical future scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale
* Adjusts hypothetical future scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale
* is set so one dimension fills the view and the image is centered on the other dimension. Used to calculate what the target of an
* is set so one dimension fills the view and the image is centered on the other dimension. Used to calculate what the target of an
* animation should be.
* animation should be.
* @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached.
*
* @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached.
* @param scaleAndTranslate The scale we want and the translation we're aiming for. The values are adjusted to be valid.
* @param scaleAndTranslate The scale we want and the translation we're aiming for. The values are adjusted to be valid.
@@ -878,7 +866,7 @@ public class SubsamplingScaleImageView extends View {
...
@@ -878,7 +866,7 @@ public class SubsamplingScaleImageView extends View {
floatmaxTy;
floatmaxTy;
if(panLimit==PAN_LIMIT_CUSTOM&&isImageReady()){
if(panLimit==PAN_LIMIT_CUSTOM&&isImageReady()){
maxTx=Math.max(0,0);
maxTx=Math.max(0,0);
maxTy=Math.max(0,getHeight()/10);
maxTy=Math.max(0,getHeight()/10);
}elseif(center){
}elseif(center){
maxTx=Math.max(0,(getWidth()-scaleWidth)/2);
maxTx=Math.max(0,(getWidth()-scaleWidth)/2);
maxTy=Math.max(0,(getHeight()-scaleHeight)/2);
maxTy=Math.max(0,(getHeight()-scaleHeight)/2);
...
@@ -896,6 +884,7 @@ public class SubsamplingScaleImageView extends View {
...
@@ -896,6 +884,7 @@ public class SubsamplingScaleImageView extends View {
/**
/**
* Adjusts current scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale
* Adjusts current scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale
* is set so one dimension fills the view and the image is centered on the other dimension.
* is set so one dimension fills the view and the image is centered on the other dimension.
*
* @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached.
* @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached.
*/
*/
privatevoidfitToBounds(booleancenter){
privatevoidfitToBounds(booleancenter){
...
@@ -916,19 +905,19 @@ public class SubsamplingScaleImageView extends View {
...
@@ -916,19 +905,19 @@ public class SubsamplingScaleImageView extends View {