resize gif animation in android

Meghs

I want to resize a gif animation so that 1 of my button fit on the screen. I am using WebView for gif animation. When I am inserting a image button it is not getting displayed. Please Help.

<RelativeLayout xmlns:android="schemas.android.com/apk/res/android"; xmlns:tools="schemas.android.com/tools"; 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".Activity_B" > 

    <ImageButton android:id="@+id/imageButton1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentTop="true" 
        android:src="@drawable/back" /> 

</RelativeLayout>
Vikram

Where do you define your WebView? See if this works for you:

<RelativeLayout xmlns:android="schemas.android.com/apk/res/android"; xmlns:tools="schemas.android.com/tools"; 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".Activity_B" > 

    <ImageButton android:id="@+id/imageButton1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentTop="true" 
        android:src="@drawable/back" /> 

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageButton1" />

</RelativeLayout>

Edit 1:

Let's say the layout file with RelativeLayout and ImageButton is called mainLayout.xml. Do the following:

View mainView = getLayoutInflater().inflate(R.layout.mainLayout, null);

RelativeLayout rlContainer = (RelativeLayout) mainView.findViewById(R.id.rlContainer);

GIFWebView view = new GIFWebView (this, "file:///android_asset/imageedit_ball.gif");

RelativeLayout.LayoutParams wvParams = new RelativeLayout.LayoutParams(
                                              RelativeLayout.LayoutParams.MATCH_PARENT,
                                              RelativeLayout.LayoutParams.MATCH_PARENT);

wvParams.addRule(RelativeLayout.BELOW, R.id.imageButton1);

rlContainer.addView(view, wvParams);

setContentView(mainView);

Give your RelativeLayout an id:

android:id="@+id/rlContainer"

<RelativeLayout xmlns:android="schemas.android.com/apk/res/android"; xmlns:tools="schemas.android.com/tools"; 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".Activity_B"
    android:id="@+id/rlContainer" > 

    <ImageButton android:id="@+id/imageButton1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentTop="true" 
        android:src="@drawable/back" /> 

</RelativeLayout>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related