Skip to content

Commit

Permalink
添加初始imageView scaleType fitXY demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ielse committed Nov 14, 2018
1 parent f71c9a2 commit c65a937
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/src/main/java/ch/ielse/demo/p02/MainActivity3.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ public void onClick(View v) {
});



View vGifPicture = findViewById(R.id.vGifPicture);
Glide.with(vGifPicture.getContext()).asBitmap().load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534324920537&di=278f9d990f277cca368a118afaac196b&imgtype=0&src=http%3A%2F%2Fimg5.duitang.com%2Fuploads%2Fitem%2F201409%2F22%2F20140922013938_NZfBs.thumb.700_0.gif")
.into((ImageView) vGifPicture); // asBitmap 必须加
.into((ImageView) vGifPicture);
vGifPicture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -110,7 +109,7 @@ public void onClick(View v) {

View vCompatImage = findViewById(R.id.vCompatImage);
Glide.with(vCompatImage.getContext()).asBitmap().load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1536811355545&di=2436088f354f1a8355ea8db0a82592e0&imgtype=0&src=http%3A%2F%2Fgss0.bdstatic.com%2F7LsWdDW5_xN3otebn9fN2DJv%2Fdoc%2Fpic%2Fitem%2F3801213fb80e7bec392a30d9232eb9389b506b11.jpg")
.into((ImageView) vCompatImage); // asBitmap 必须加
.into((ImageView) vCompatImage); //
vCompatImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -126,6 +125,20 @@ public void onClick(View v) {
});


final String urlFitXY = "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=393198154,1291067317&fm=15&gp=0.jpg";
ImageView vFitXyImage = findViewById(R.id.vFitXyImage);
Glide.with(vCompatImage.getContext()).asBitmap().load(urlFitXY)
.into(vFitXyImage); //
vFitXyImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final List<String> longPictureList = new ArrayList<>();
longPictureList.add(urlFitXY);
final SparseArray<ImageView> mappingViews = new SparseArray<>();
mappingViews.put(0, (ImageView) v);
iwHelper.show((ImageView) v, mappingViews, convert(longPictureList));
}
});
}

private List<Uri> convert(List<String> data) {
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/layout/activity_main3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@
android:layout_marginLeft="20dp"
android:background="#CCC"
android:scaleType="centerCrop" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="scaleType fitXY " />

<android.support.v7.widget.AppCompatImageView
android:id="@+id/vFitXyImage"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:background="#CCC"
android:scaleType="fitXY" />
</LinearLayout>


Expand Down

0 comments on commit c65a937

Please sign in to comment.