2017-11-22 2 views
1

Meine Bildansicht ändert sich nicht, wenn ich entweder "centerCrop" oder "center" versuche. Was ist das Problem zu lösen, damit ich das Bild zuschneiden kann?imageview-cropping funktioniert nicht

<RelativeLayout 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="xx.myapplication.MainActivity"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@drawable/party" 
      android:scaleType="centerCrop" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="From. h" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentBottom="true" 
       android:layout_margin="8dp" 
       android:padding="8dp" 
       android:textSize="20sp" 
       android:textColor="#FFEBEE" 
       android:fontFamily="sans-serif-medium" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Happy Wednesday!!" 
       app:layout_constraintBottom_toBottomOf="parent" 
       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintRight_toRightOf="parent" 
       app:layout_constraintTop_toTopOf="parent" 
       android:layout_margin="8dp" 
       android:textSize="36sp" 
       android:textColor="@android:color/white"/> 

    </RelativeLayout> 

Bild, das ich mit meinem Code sehen:

Image that I see with my code now is here<<

+0

immer Inline-Bilder durch Voranstellen ein "!" vor dem Bildlink, so dass andere es sehen können, ohne einen Link zu öffnen. – EvilTak

+0

@EvilTak Sagst du, wenn ich "!" Vor dem Bildlink würde es das Bild direkt auf dieser Seite zeigen, anstatt den Betrachter zu bitten, darauf zu klicken? – learningcur

+0

Ja, ich bin. Schauen Sie sich meine [edit] (https://stackoverflow.com/posts/47440001/revisions) an. – EvilTak

Antwort

1

Verwenden src statt background

android:src="@drawable/party" 
-1

kann nicht wirklich helfen, ohne zu sehen, was Sie vielleicht auf Ihre Java-Datei an die Armen Imageview tun. Aber ich denke, was können Sie versuchen, tun das folgt:

  1. Android Studio einen Neustart durch die Cashes ungültig zu machen, tun dies immer, wenn Ihr Programm ist lustig zu sein (nicht immer)

  2. Deaktivieren Sie die App oder deinstallieren es von Ihrem Testgerät oder Emulator, manchmal könnte es wegen der Instant Build sein.