2016-02-25 84 views
1

:) 我正在使用ImageView,並在其中顯示gif。問題是,例如這個gif:http://media3.giphy.com/media/110U0ZUA6mPxqE/200.gif有不同的尺寸比這個:http://media0.giphy.com/media/10YsmVhdN1S6wE/200.gif和我在列表視圖中顯示gif。具有或多或少相同高度和寬度的gif顯示良好。但是,其中有不合理不同的寬度和heigt的GIF只顯示GIF的一部分。這 這是我的項目:Android:將ImageView(GIF)的大小設置爲源的尺寸

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 



    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal"> 

     <ImageView 
      android:id="@+id/imageViewGif" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:adjustViewBounds="true" 
      android:scaleType="fitCenter" 
      android:minWidth="300dp" 
      android:visibility="visible" /> 
    </LinearLayout> 

    <ProgressBar 
     android:id="@+id/progressBarSearchedGif" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" /> 

</RelativeLayout> 

綜上所述,問題是我怎麼能顯示完整的GIF在我的ImageView甚至當GIF的尺寸不同時。

+0

請將您的加載gif的源代碼添加到ImageView。 –

回答

0

您可以嘗試移除android:scaleType =「fitCenter」,並將android:adjustViewBounds =「true」設置爲您的圖像視圖。

+0

不起作用... – blueman3399

0

如果您始終希望整個圖像顯示在ImageView中,您有兩種選擇。您可以拉伸它以適合的ImageView與此選項大小:

android:scaleType="fitXY" 

或者你也可以減少圖像的大小,以適合的ImageView不改變其長寬比:

android:scaleType="centerInside" 

參考到javadoc瞭解詳情。

+0

不起作用... – blueman3399