简体   繁体   中英

Resize the image in Android (Gallery view)

I am writing an application to customize the home application, where I am getting the images of all applications and displaying it in the gallery view. Now, what I want is to change the image size and the rotation angle of the images based on the right, left and center. I used the code

<Gallery android:id="@+id/gallery"
    android:background="#70000000"
    **android:layout_width="match_parent"
    android:layout_height="60dip"**
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:gravity="center_vertical"
    android:spacing="16dp"
/>

To change the size, but I am getting the default size of images for the default application, whereas for third-party images I am getting bigger images what size I am specifing. I want all images to be equal of size.

If you set the attributes below to GridView then it's for GridView only, not for the GridView items.

android:layout_width="match_parent"
android:layout_height="60dip

If you want to fix the height and width of the GridView items, you can define a custom adapter for the GridView by taking a custom row layout. Define a custom row layout with 1 imageview with your desired height and width, and by using the same row xml layout, define a custom adapter for the GridView and use the same adapter to set inside the GridView .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM