I'm trying to make the image display full screen when imageView
is clicked.
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
if (isImageFitToScreen) {
isImageFitToScreen = false;
imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.CENTER);
} else {
isImageFitToScreen = true;
imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
}
}
});
xml
<ImageView
android:layout_gravity="center"
android:layout_width="214dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@mipmap/no_image"
android:id="@+id/imageView"
android:layout_weight="0.19" />
Before the imageView
is clicked, the imageView
is in center. when it clicked and then back to normal size, the size of imageView
become smaller and it moves to left-hand side. How do I make the size remains the same as normal (before zoom in) and fix imageView in center ?