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>