2016-02-25 82 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