Pradyut Bhattacharya
Pradyut Bhattacharya

Reputation: 5748

Android Gif ImageView unable to set width to match parent

I m using GifImageView from here.

With the below code(without min-height) it just shows a thumbnail size of the gif -

<LinearLayout
            android:id="@+id/linear_one"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/linearlayout1">

            <pl.droidsonroids.gif.GifImageView
                android:id="@+id/gif"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                />
        </LinearLayout>

the screenshot below shows the third image as the gif.

enter image description here

I had to set the min-height of the LinearLayout to 300dp so that the gif can fit the whole parent width.

<LinearLayout
            android:id="@+id/linear_one"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/linearlayout1"
            android:minHeight="300dp">

            <pl.droidsonroids.gif.GifImageView
                android:id="@+id/gif"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                />
        </LinearLayout>

Now the gif is shown in whole width but the LinearLayout has paddings as the height is 300dp. enter image description here

Upvotes: 0

Views: 178

Answers (1)

Pradyut Bhattacharya
Pradyut Bhattacharya

Reputation: 5748

android:adjustViewBounds="true"

is the answer to autoscaling for all Views.

Upvotes: 1

Related Questions