我已经将'pl.droidsonroids.gif.GifImageView'用于gif图像。但它默认大小。如果我尝试给出一些宽度和高度,它不会采取给定的大小,它默认为apper。
我的xml是:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="10"
android:layout_marginTop="@dimen/_1sdp"
android:layout_marginBottom="@dimen/_30sdp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_weight="7.4">
<pl.droidsonroids.gif.GifImageView
android:id="@+id/gifImageView2"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/hubcreategif1"
android:layout_marginTop="0dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3.0"
android:layout_marginBottom="0dp"
android:gravity="center"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layout_hubmessage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:gravity="center"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/tv_lbldonthave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="You don't have a hub history yet."
android:layout_gravity="center_horizontal"
android:textSize="@dimen/_11sdp"
android:textColor="@color/colordarkgray"
/>
<TextView
android:id="@+id/tv_strcomeback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/strcomeback"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textSize="@dimen/_11sdp"
android:textColor="@color/colordarkgray"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/_17sdp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_onboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/_15sdp"
android:layout_marginRight="@dimen/_15sdp"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/tv_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/_22sdp"
android:text="@string/strcreateorjoin"
android:gravity="center_horizontal"
android:layout_marginTop="1dp"
android:layout_gravity="center_horizontal"
android:textColor="@color/colorBlack"/>
<TextView
android:id="@+id/tv_2"
android:layout_width="match_parent"
android:layout_marginLeft="@dimen/_35sdp"
android:layout_marginRight="@dimen/_35sdp"
android:layout_height="@dimen/_2sdp"
android:layout_marginTop="@dimen/_7sdp"
android:background="@drawable/dotted_bottom_textview_black"
/>
<TextView
android:id="@+id/tv_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_10sdp"
android:layout_marginRight="@dimen/_10sdp"
android:textSize="@dimen/_11sdp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/strhubdetail"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_marginTop="@dimen/_5sdp"
android:textColor="@color/colordarkgray"/>
<TextView
android:id="@+id/tv_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_10sdp"
android:layout_marginRight="@dimen/_10sdp"
android:textSize="@dimen/_11sdp"
android:text="@string/strhubabort"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_marginTop="@dimen/_11sdp"
android:visibility="gone"
android:textColor="@color/colordarkgray"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_weight="2.5"
android:layout_height="0dp" />
</LinearLayout>
</RelativeLayout>
和java类是:
gifImageView =(pl.droidsonroids.gif.GifImageView)findViewById(R.id.gifImageView2);
别无其他答案 0 :(得分:0)
您可以通过设置以下android:layout_width
和android:layout_height
这应该有效:
<pl.droidsonroids.gif.GifImageView
android:layout_width="10dp" <-- your width
android:layout_height="10dp" <-- your height
android:src="@drawable/src_anim"
android:background="@drawable/bg_anim" />