0
私はTouchImageViewからViewPager
を使用して画像をアプリケーションにロードしています。これは画像の読み込みを担当するです。カスタムイメージビューで画像を一番上に整える
float redundantXSpace = viewWidth - (scaleX * drawableWidth);
float redundantYSpace = viewHeight - (scaleY * drawableHeight);
matchViewWidth = viewWidth - redundantXSpace;
matchViewHeight = viewHeight - redundantYSpace;
if (!isZoomed() && !imageRenderedAtLeastOnce) {
//
// Stretch and center image to fit view
//
matrix.setScale(scaleX, scaleY);
matrix.postTranslate(redundantXSpace/2, redundantYSpace/2);
normalizedScale = 1;
} else {
//
// These values should never be 0 or we will set viewWidth and viewHeight
// to NaN in translateMatrixAfterRotate. To avoid this, call savePreviousImageValues
// to set them equal to the current values.
//
if (prevMatchViewWidth == 0 || prevMatchViewHeight == 0) {
savePreviousImageValues();
}
prevMatrix.getValues(m);
コードは、縦の中心に画像を読み込みます。私が達成したいのは、垂直上にイメージをロードすることです。 matchViewHeight = viewHeight - redundantYSpace;
をmatchViewHeight = viewHeight;
に変更すると、画像全体の高さが表示されます。垂直上に整列させるためにどのような変更を行う必要がありますか?
おかげで、しかし、 'ViewPager'をスライド上のこの唯一の作品。私はそれをスライドから解放した後、画像は垂直方向の中心に戻る。 – user2872856
メソッド 'setZoom(float scale、float focusX、float focusY、ScaleType scaleType)で置き換えを試みてください。 \t m [Matrix.MTRANS_Y] = - ((focusY * getImageHeight()) - (viewHeight * 0.5f));' 'm [Matrix.MTRANS_Y] = 0;'にあります。行列を変更した場所を確認してください。 – KosWarm
まだ動作しません。コードは複雑なようです。とにかく、私はあなたに感謝の意を表します。 – user2872856