2017-11-20 2 views
0

画像があります。画像の幅は高さよりも大きいです。私は幅を切り取って画像を高さに合わせたい。それはascpectRatioを保存するはずです。イメージはイメージビューに収まる必要があります。 XMLでandroid:scaleType="centerCrop"のプロパティを使用しようとしましたが、同じ結果を得られませんでした。画像が高さに収まらない

私は android:scaleType="fitXY" android:adjustViewBounds="true"

を試してみましたあなたは、私を助けてくださいもらえますか? 以下はXMLファイルです。

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="riskmatix.be.bouwcampusvirtualtour.home.HomeActivity"> 

<ImageView 
    android:id="@+id/background_image" 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:adjustViewBounds="true" 
    android:scaleType="fitXY" 
    android:src="@drawable/day" 
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintEnd_toEndOf="parent" 
    app:layout_constraintStart_toStartOf="parent" 
    app:layout_constraintTop_toTopOf="parent" /> 

+1

をmatch_parentする幅と高さを設定する必要が 、これを試してみてください、あなたが –

+0

あなたのXMLをしてください投稿やスクリーンショットを投稿しますvexを追加しました。 – diegoveloper

+0

申し訳ありません@Vivek、私は」ことができるかどうか – sofi37

答えて

0

あなたは

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:src="@drawable/ati" 
    android:scaleType="centerCrop" 
    android:adjustViewBounds="true"/> 
+0

申し訳ありませんが、私はイメージの一部を中心にする必要はありません。 – sofi37

+0

あなたは左側か右側が必要ですか? –

+0

私は1つ左にする必要があります – sofi37

関連する問題