How to implement Image Gallery in Gridview in android?

Use this XML for Layout : gallery.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:background=”@drawable/bg_child”> <FrameLayout android:id=”@+id/FrameLayout01″ android:layout_width=”fill_parent” android:layout_height=”fill_parent”> <FrameLayout android:id=”@+id/LinearLayout01″ android:layout_gravity=”top” android:layout_height=”50dp” android:layout_width=”fill_parent”> <TextView android:id=”@+id/TextView01″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:textStyle=”bold” android:layout_gravity=”center_vertical” android:layout_marginLeft=”30dp” android:gravity=”center_vertical” android:drawableLeft=”@drawable/photo_frame” android:textColor=”@color/grey” android:text=”@string/photogallery_txt”></TextView> <Button android:layout_gravity=”right” android:id=”@+id/btnMoreInfo” android:layout_marginRight=”5dp” android:layout_marginTop=”5dp” android:textStyle=”bold” android:background=”@drawable/my_child_button” android:layout_width=”100dp” android:layout_height=”40dp” android:text=”@string/moreinfo_txt”></Button> </FrameLayout> <GridView xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/gridview” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:columnWidth=”90dp” android:numColumns=”auto_fit” android:verticalSpacing=”10dp” … Read more

How to get the Correct orientation of the image selected from the Default Image gallery

If the image(photo) was taken by a program made by you, you must set Parameters.setRotation with the correct rotation value. This, depending of camera drive, rotates the image before save or save the rotation value to exif TAG_ORIENTATION. Therefore, if TAG_ORIENTATION is null or zero, the image are in the correct orientation, otherwise you must … Read more

Android get image from gallery into ImageView

Simple pass Intent first: Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, RESULT_LOAD_IMAGE); And you will get picture path on your onActivityResult: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA … Read more

Select multiple images from android gallery

The EXTRA_ALLOW_MULTIPLE option is set on the intent through the Intent.putExtra() method: intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); Your code above should look like this: Intent intent = new Intent(); intent.setType(“image/*”); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent,”Select Picture”), 1); Note: the EXTRA_ALLOW_MULTIPLE option is only available in Android API 18 and higher.

android get real path by Uri.getPath()

This is what I do: Uri selectedImageURI = data.getData(); imageFile = new File(getRealPathFromURI(selectedImageURI)); and: private String getRealPathFromURI(Uri contentURI) { String result; Cursor cursor = getContentResolver().query(contentURI, null, null, null, null); if (cursor == null) { // Source is Dropbox or other similar local file path result = contentURI.getPath(); } else { cursor.moveToFirst(); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); … Read more