Reputation: 111
Simple: How to set imageView to full screen on setOnClickListener? Is this possible? If the answer is no, there is another method to do it? Thank you very much
Upvotes: 0
Views: 602
Reputation: 1483
yes it is possible, try this: First declare a global after your Activity/Fragment definition
boolean isImageFitToScreen=false;
_imageView= (ImageView) findViewById(R.id.yourimageView);
_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);
}else{
isImageFitToScreen=true;
imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
}
}
});
That should Works.
Regards.
Upvotes: 0
Reputation: 678
The most basic way to do it using dialog.
Create a dialog having image view as a layout.
Set the dialog window feature to no title.
Set the dialog theme to full screen using android style.
Once click on image. Pass the image resouce reference to the dialog and open the dialog with same image.
Alternatively you can also seaech for some third party libraries and can use it. They might give some more feautered experience.
Upvotes: 2