Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when single image make width to match_parent. #17

Open
The-RobinHood opened this issue Apr 8, 2016 · 2 comments
Open

when single image make width to match_parent. #17

The-RobinHood opened this issue Apr 8, 2016 · 2 comments
Labels

Comments

@The-RobinHood
Copy link

Hello,

Can it be possible to make image width to match_parent( same as device width) when there is only one image in list? I just apply below code but no luck.

        int imgWidth = width[0] * (int) mContext.getResources().getDisplayMetrics().density;
        int imagHeight = height[0] * (int) mContext.getResources().getDisplayMetrics().density;
        int height = (deviceWidth * imagHeight) / imgWidth;

       holder.imageView.getLayoutParams().height = height;
        holder.imageView.getLayoutParams().width = deviceWidth;

device-2016-04-08-121748

@The-RobinHood The-RobinHood changed the title width match_parent single image. when single image make width to match_parent. Apr 8, 2016
@alashow
Copy link

alashow commented Apr 8, 2016

Return bigger aspectRatio when your itemList(your data array) count is 1.

@Override
public double aspectRatioForIndex(int index) {

    // ...

    if (mData.size() == 1) return 10.0; //10 is just example, can be smaller or bigger

    // ...
}

@The-RobinHood
Copy link
Author

but again it will be problem with height, its not wrapping the height.

@beltex beltex added the question label Apr 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants