2015-11-13 96 views
0

我有一個SimpleDraweeView這是一個回收站。如何獲得SimpleDraweeView以正確顯示圖像?

回收站:

<android.support.v7.widget.RecyclerView 
    android:id="@+id/recycler_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

SimpleDraweeView:

<com.facebook.drawee.view.SimpleDraweeView 
      android:id="@+id/feedImage" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      /> 

我嘗試了很多比scaleType的,但我似乎無法得到一個將顯示全高(只有90%被展示)。寬度很好,但我似乎無法正確獲得高度。獲得適當的方面是正確的組合? (臉譜等)

回答

1

我真的不明白你在尋找什麼樣的規模型的,但它肯定會通過壁畫的lib配置具有以下特性之一:

fresco:actualImageScaleType="focusCrop|centerCrop|..." 
    fresco:placeholderImageScaleType="fitCenter" 

說你有一些固定高度和100%寬度的imageView:

<com.facebook.drawee.view.SimpleDraweeView 
     android:id="@+id/feedImage" 
     android:layout_width="match_parent" 
     android:layout_height="200dp" 
     fresco:actualImageScaleType="centerInside" /> 
+0

我只想看到整個圖像。就像它在畫廊或網站上顯示的一樣。 –

+0

無論我使用哪一個,我只能看到圖像高度的85% –

+0

我通常會使用centerCrop,因此您將填充imageView,但如果您希望它適合中心(所有部分都可見並且沒有裁剪) ,那麼會有邊距,因爲你的imageView可能是固定的高度和寬度 –

0

我的假設是你有一個與父視圖相關聯的邊距。請完全鏈接您的XML文件,但最有可能的是有一個RelativeLayout設置了保證金。

另一件事,我在SimpleDraweeView中看到這個android:layout_height =「wrap_content」。寬度將匹配父級,並且高度設置爲wrap_content,因此如果沒有這個,它不會將高度擴展爲100%。這就是爲什麼有90%的圖像填充。更改爲以下:

比我需要看到的XML,以確定是否還有別的東西造成這種
<com.facebook.drawee.view.SimpleDraweeView 
     android:id="@+id/feedImage" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:adjustViewBounds="true" 
     /> 

其他!

+1

我試圖爲兩個參數使用match_parent,但由於某種原因,圖像不會顯示一行。我在git上發佈了它,他們說因爲我的Image是在一個Recycler中,它沒有用於match_parent的參數。 –