InAppメッセージと呼ばれるものを実装しています。サイズ変更後にImageViewを画像サイズに合わせようとしています。サイズ変更後の画像サイズに合わせる
これは私のImageViewのである:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="40dp"
android:padding="6dp">
--other components--
<ImageView
android:id="@+id/middleLayoutImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:padding="5dp"
app:layout_constraintBottom_toTopOf="@+id/middleLayoutText"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/topWrapper"
app:layout_constraintVertical_chainStyle="packed" />
--other components--
</android.support.constraint.ConstraintLayout>
のimgをダウンロードして、このビューに配置するには、私はピカソを使用しています:今 Before fitting
:
Picasso.with(getApplicationContext())
.load(inputurl)
.into(imageView);
は今、私の活動は、このようになります親レイアウトの縦横比でサイズを変更したいと思います。私は成功しませんたくさんのODの組み合わせを試してみた:
アンドロイド:scaleType = "fitXY" - stretched img
ピカソフィット()centerCrop() - centerCrop
ピカソフィットを。 ().centerInside() - centerInside
よりアンドロイドとの組み合わせ:adjustViewBoundsのscaleTypes等
Resized correctly - この場合、私はpicasso:.resize(2000,500).centerInside()を使用しましたが、この場合のみ動作します。自動的に?助けを事前に感謝 :)
編集:Picasso
については
ImageView imageView = (ImageView) findViewById(R.id.middleLayoutImage);
String inputurl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSQtqf1EUqH4eQNNqYFbSawpiR5bypfOhvlatgS0mC3Ve1nk2adbw"; //http://www.gatesms.eu/img/android.png";
Picasso.with(getApplicationContext())
.load(inputurl)
.resize(2000,500)
.centerInside()
.into(imageView);
ピカソをロードしたあなたの活動や断片を見せてください! – Xenolion
上記の "編集"の部分を見て、私は期待した結果を出しますが、このソリューションはこの場合にのみ動作します。あなたがmatch_constriantまたは0dp –
は、それが完璧に動作し、本当にありがとうございます:あなたは歓迎されている – elmorabea