Spread the image on the whole screen in HorizontalScrollView



  • The project is dynamically receiving objects that contain certain data and images. All the information I'm putting in activitywhich includes the root layout ScrollView♪ At the end of this. ScrollView I'm lying. HorizontalScrollViewwhich I'm putting on the n-number ImageView, thus:

    final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
            for (int i = 0; i < hotel.getImages().size(); i++) {
    
            final int finalI = i;
            hotelImagesLayout.post(new Runnable() {
                @Override
                public void run() {
                    ImageView hotelImage = new ImageView(context);
                    hotelImage.setAdjustViewBounds(true);
                    hotelImage.setLayoutParams(params);
                    Picasso.with(context)
                            .load(hotel.getImages().get(finalI))
                            .placeholder(R.drawable.place_holder)
                            .transform(transformation)
                            .into(hotelImage);
                    hotelImagesLayout.addView(hotelImage);
                }
            });
    
    
        }
    

    The pictures will be fine, the horizontal will allble, too, okay, but I need the first picture to reach the entire screen, the size of the motto, not to keep its old bread and the value.

    Here's the mark where the image is:

     <HorizontalScrollView
    android:id="@+id/horizontalLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_below="@+id/regionAndName"
    android:layout_marginTop="10dp">

                &lt;LinearLayout
                    android:id="@+id/hotelImagesLayout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:orientation="horizontal" /&gt;
    
            &lt;/HorizontalScrollView&gt;
    

    How to pull the image under the screen wide horizontalScrollView? I tried to play with scaleType, but something didn't work.



  • You'll have to count the height and width.
    I mean, after the imaging's download, you need to ask for it. ImageView width and height corresponding to the size of your screen.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2