2016-06-21 13 views
0

Ich habe ein Bild oben in einer Kartenansicht. Es hat einen kleinen (unerwünschten) Spielraum und ich weiß nicht warum ... Vielleicht kann mir jemand einen Hinweis geben, wie ich das beheben kann? Danke vielmals!Bild in Cardview hat Rand auf der rechten Seite

Wenn ich "adjustViewBounds" nicht verwende, funktioniert es. Aber ich brauche es für weitere Ansichten unter dem Bild.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dp" 
     android:layout_marginBottom="10dp" 
     android:layout_marginStart="10dp" 
     android:layout_marginEnd="10dp"> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 
    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/nature" 
     android:scaleType="fitStart" 
     android:adjustViewBounds="true" 
     android:id="@+id/exercise_picture"/> 
     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Test"/> 
     </LinearLayout> 
</android.support.v7.widget.CardView> 
</RelativeLayout> 
+0

statt xmlns: Werkzeuge = "http://schemas.android.com/tools" Verwendung xmlns: app = "http://schemas.android.com/apk/res-auto" – Amir

Antwort

0

Versuchen Sie, den ImageView-scaleType auf etwas zu setzen, das den gesamten zur Verfügung gestellten Platz wie cropCenter ausfüllt.

Mit fitStart wird das gesamte Bild in den Raum eingefügt und das Seitenverhältnis beibehalten. Da das Bild ein wenig größer als das CardView ist und Sie es auf "FitStart" einstellen, kann auf der rechten Seite etwas mehr Platz sein.

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:src="@drawable/nature" 
    android:scaleType="cropCenter" 
    android:adjustViewBounds="true" 
    android:id="@+id/exercise_picture"/> 
+0

Danke , Es klappt! – Raspberry

Verwandte Themen