There is an ImageView. How to increase this ImageView by clicking on it and returning to the standard size after a second click?
Googling found such a code. It seems everything works, but after repeated pressing it does not return the original size of the ImageView.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="550dp" android:layout_height="350dp" android:layout_centerVertical="true" android:layout_centerHorizontal="true"> <ImageView android:layout_width="50dp" android:layout_height="50dp" android:id="@+id/btn3" android:adjustViewBounds="true" android:src="@drawable/history_button" android:layout_marginTop="250dp" /> </LinearLayout> MainActivity
button3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(isImageFitToScreen) { isImageFitToScreen=false; button3.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); button3.setAdjustViewBounds(true); }else{ isImageFitToScreen=true; button3.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); button3.setScaleType(ImageView.ScaleType.FIT_XY); } } }); 