2017-11-20 5 views
0

Ich habe ein Bild, wo die Breite größer als Höhe ist. Ich möchte das Bild in der Höhe anpassen und die Breite zuschneiden. Es sollte ascpectRatio speichern. Das Bild sollte in die Bildansicht passen. Ich habe versucht, android:scaleType="centerCrop" Eigenschaften in XML, aber ich habe nicht das gleiche.Bild passt nicht in Höhe

Ich versuchte android:scaleType="fitXY" android:adjustViewBounds="true"

Könnten Sie mir bitte helfen? Unten ist die XML-Datei.

<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

posten Sie Ihre xml bitte –

+0

und Post einen Screenshot match_parent wenn Sie – diegoveloper

+0

@Vivek Sorry, I‘ ve added xml – sofi37

Antwort

0

dies versuchen, Sie müssen die Breite und Höhe einstellen

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

Entschuldigung, aber ich muss keinen Teil des Bildes zentrieren. – sofi37

+0

Sie brauchen die linke oder rechte Seite? –

+0

Ich brauche links eins – sofi37