I want to enlarge an image of imageView
ie make that effect of whatsapp when you receive an image and the user clicks on the image it opens.
I want to enlarge an image of imageView
ie make that effect of whatsapp when you receive an image and the user clicks on the image it opens.
I'll put " cat jump " just because the example I made is very large:
I was using GridView
to display all the images but you can have a imageView
normal.
grid = (GridView) findViewById(R.id.gridview);
adapter = new GridViewAdapter(this, FilePathStrings, FileNameStrings);
grid.setAdapter(adapter);
grid.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Intent i = new Intent(MainActivity.this, ViewImage.class);
i.putExtra("filepath", FilePathStrings);
i.putExtra("filename", FileNameStrings);
i.putExtra("position", position);
startActivity(i);
}
});
Here is the activity that will be started in the photo click:
public class ViewImage extends Activity {
ImageView imageview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_image);
Intent i = getIntent();
int position = i.getExtras().getInt("position");
String[] filepath = i.getStringArrayExtra("filepath");
imageview = (ImageView) findViewById(R.id.full_image_view);
Bitmap bmp = BitmapFactory.decodeFile(filepath[position]);
imageview.setImageBitmap(bmp);
}
}
Here is the full screen layout after clicking the photo:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/full_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
This was my solution because I had a product description with an image of it below and needed the user to see the image in larger size, I only changed the GridView
to ImageView
when I was deploying.