Ich möchte ein Bild in ein ImageView einfügen, das als Hintergrund verwendet wird. Dieser Hintergrund ist in einer RecyclerView. Wenn es das erste Mal geladen wird, sieht es wie folgt aus:Picasso centerCrop und fit erhalten unterschiedliche Ergebnisse
Aber wenn ich zu einem anderen Element scrollen und blättern zurück, sieht es wie folgt aus (es sollte immer so aussehen):
Hier füge ich das Bild:
public void onBindViewHolder(StoryViewHolder holder, int position) {
holder.cardView.setMinimumHeight(height/3);
holder.layout.setMinimumHeight((int) ((float) width/4));
//set image
Picasso.with(activity).load(MainPostAdapter.URL + 140 + ".png").
transform(new BlurTransform(holder.background.getContext())).fit().centerCrop().into(holder.background);
holder.background.setAlpha(0.25f);
}
Und das ist das Bild selbst:
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/story_view_background"/>
Was könnte das Problem sein?
EDIT: ganze XML (. Es ist nicht der gesamte Code zeigen Hier ist auch Pastebin: http://pastebin.com/8rJvSx7V):
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/story_view_background"/>
<RelativeLayout
android:id="@+id/story_view_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="50px">
<ImageView
android:id="@+id/story_view_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/story_view_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:layout_below="@+id/story_view_image"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</FrameLayout>
zeigen mehr XMLs, könnte die sein Problem. Ihr 'ImageView' sollte wahrscheinlich eine andere Breite und Höhe haben – snachmsm
@snachmsm Ich habe es aktualisiert. – user6586661