1
我有一個適配器,它將圖像加載到ImageView和Picasso,直到這裏一切正常。 問題是我被自己處理方向的變化:Android Picasso處理方向已更改
android:configChanges="orientation|keyboardHidden|screenSize"
,我不能讓畢加索重新加載圖像,並正確地安裝它的ImageView的方向改變後。
if (imageUrlString == null) {
Picasso.with(context).load(R.drawable.image_adega).fit().centerCrop()
.into(headerHolder.img_store);
} else {
Picasso.with(context).load(imageUrlString).fit().into(headerHolder.img_store);
}
而且在我的活動:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (adapter != null) {
adapter.reloadPicasso(getActivity());
}
}
XML:
<ImageView
android:id="@+id/img_store"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_centerHorizontal="true"
android:adjustViewBounds="false"/>
感謝
你能發佈你的佈局XML文件的樣子嗎? – bodagetta
添加了xml片段 – firetrap
在方向更改後,您不需要強制重新加載圖像。圖像大小由ImageView控制。嘗試將android:scaleType =「centerCrop」添加到您的佈局XML – bodagetta