0

我想调整 gif 动画的大小,以便我的 1 个按钮适合屏幕。我正在使用 WebView 进行 gif 动画。当我插入图像按钮时,它不会显示。请帮忙。

<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>
4

2 回答 2

2

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>
于 2013-08-17T06:44:28.200 回答
0

请添加相对布局,然后将第一个按钮和第二个 webview 放入相对布局。

于 2013-08-17T05:56:28.090 回答