• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How can I center inside my image using ScaleType.MATRIX in ImageSwitcher

I am using ImageSwitcher and TouchImageView (source code here https://github.com/gabu/AndroidSDK-...example/android/recipe060/TouchImageView.java)

My image need to CENTER_INSIDE during initial display then enable dragging and zooming by setting the ScaleType to MATRIX.

The problem is, I can't set the two types. For now I am using MATRIX then set manually the values in order to get the image center inside the view.

Here's my fixed values (want this to be automatically computed depends on the image size):

Code:
imageView.setImageMatrix(createDefaultMatrix());

private Matrix createDefaultMatrix() {
    Matrix matrix = new Matrix();
    matrix.setValues(new float[]{1.136f, 0.0f, -17.204117f,0.0f, 1.136f, 66.24078f,0.0f, 0.0f, 1.0f});
    matrix.postScale(1.1085271f, 1.1085271f, 198.08646f, 304.4192f);
    return matrix;
}
Any guidance is appreciated.
 
Back
Top Bottom