There is a set of six ImageButton
with specified width and height parameters. These parameters can change depending on which device the buttons are displayed on, but at the moment they are constant, since the device is the same. As well as 6 images of 200 х 200
<ImageButton android:id="@+id/RG_SS_Button1" android:layout_width="100dp" android:layout_height="100dp" android:layout_marginTop="5dp"/>
When using Picasso
, the following code is used to populate all 6 buttons.
Picasso.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[0]).placeholder(R.drawable.loading_white).fit().centerCrop().into(RG_SSButton1); Picasso.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[1]).placeholder(R.drawable.loading_white).fit().centerCrop().into(RG_SSButton2); Picasso.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[2]).placeholder(R.drawable.loading_white).fit().centerCrop().into(RG_SSButton3); Picasso.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[3]).placeholder(R.drawable.loading_white).fit().centerCrop().into(RG_SSButton4); Picasso.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[4]).placeholder(R.drawable.loading_white).fit().centerCrop().into(RG_SSButton5); Picasso.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[5]).placeholder(R.drawable.loading_white).fit().centerCrop().into(RG_SSButton6);
This automatically determines the size of the target object in which the image is placed, the image is proportionally reduced to these dimensions, and the excess is cut off.
All this is fine, but it creates some delay, due to the fact that time is spent on determining these object dimensions themselves.
Theoretically, this deficiency is devoid of Glide
, which measures automatically without losing time to determine. But for some reason he does not want to fit the image in the button completely. Instead, he seems to put a picture 200 х 200
in size and then trim the excess.
Glide.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[0]).placeholder(R.drawable.loading_white).fitCenter().into(RG_SSButton1); Glide.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[1]).placeholder(R.drawable.loading_white).fitCenter().into(RG_SSButton2); Glide.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[2]).placeholder(R.drawable.loading_white).fitCenter().into(RG_SSButton3); Glide.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[3]).placeholder(R.drawable.loading_white).fitCenter().into(RG_SSButton4); Glide.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[4]).placeholder(R.drawable.loading_white).fitCenter().into(RG_SSButton5); Glide.with(RunGallery_SmallSpeed.this).load(RG_SS_V1[5]).placeholder(R.drawable.loading_white).fitCenter().into(RG_SSButton6);
I tried both options. And .fitCenter()
and .centerCrop()
. The result is the same.
Tell me please. Am I using the wrong method or is Glide
still unable to work with an ImageButton
in this way?