In a project, I dynamically receive objects that contain in themselves some data and paths to images. I bring all the information to the activity
, which includes the root layout ScrollView
. At the end of this ScrollView
I have a HorizontalScrollView
on which I programmatically put the n-oe ImageView
number, 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); } }); }
Pictures are laid normally, horizontally, too, everything is scrolling ok, but! I need the first picture to stretch across the entire screen, to the size of the device, and not to retain its previous width and size.
Here is the markup where I put the images:
<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"> <LinearLayout android:id="@+id/hotelImagesLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="horizontal" /> </HorizontalScrollView>
How to make the image stretch to the width of the screen in horizontalScrollView
? I tried to play with scaleType, but something did not help.