ImageDetailsActivity for a recycler view

邮差的信 提交于 2019-12-11 11:44:07

问题


in my android app, I am listing the images' previews with network image view. I want that if user press the previews it opens an activity with viewpager and show the original images of specific item of my recycler view. So, i have a two method in my mind.

1-) I will save two image for each of my images in my database. One of them will be preview image with small size and other one will be the original one. In my main newsfeed, app will load the preview images so download size will be smaller. And if user press a preview image it will open activity and download the original one.

2-) There will be only original images in my db and i will minimize it's size after the download and if user press the preview it will show the original one directly since it is already downloaded.

I wonder which one is better method, or is there a better method than those?

This is where i set click listeners for my images:

for(int i = 0; i < listItem.getImageCount(); i++) {
        final NetworkImageView niv = new NetworkImageView(context);

        niv.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
            }
        });

        holderr.layoutImages.addView(niv);
    }

Thank you.


回答1:


You can try this:

How to reduce an Image file size before uploading to a server

The idea is, before sending to the server, that image's size would be decreased and then download it, after that(e.g - in small ImageView),

Use something like this: Full doc: http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

android:scaleType="centerCrop"

And then if the users clicked on the info Button(or whatever), the big ImageView will be shown But, with one difference between the height and weight of it than previous ImageView.

Here is an example for using that ImageView with android:scaleType="fitXY" :

<ImageView
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:contentDescription="Main Image"
   android:padding="1dp"
   android:scaleType="fitXY"
   android:src="@drawable/balloon" />

http://hmkcode.com/android-designing-whatsapp-like-user-profile-screen/

The point is, i think you don't need to store that image in your sdcard or wherever.just use it(store it) one time with the best quality :)

hope that helps.



来源:https://stackoverflow.com/questions/34818380/imagedetailsactivity-for-a-recycler-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!