Skip to content Skip to sidebar Skip to footer

Android Layout Issue With Buttons Below Webview

So I have a webview I'd like to display as a dialog. I'd like the webview to fill the entire screen, except for a button below it that I'd like to stay at the bottom of the dialog

Solution 1:

You will want to use android:layout_above="@+id/btnOk" for your webview, and do fill_parent for width and height of the webview.

However, it is important to note, that in 1.5 and below, RelativeLayout views need to be specified in order in your xml to be recognized correctly.. in other words, you have to have your Button first, then the WebView, since the WebView will reference the button. I think this has been changed in 1.6 or 2.0, but I am not positive which.

<RelativeLayoutandroid:id="@+id/RelativeLayout01"android:layout_width="fill_parent"android:layout_height="fill_parent"xmlns:android="http://schemas.android.com/apk/res/android"><Buttonandroid:text="Ok"android:id="@+id/btnOk"android:layout_width="120px"android:layout_height="wrap_content"android:layout_gravity="center_horizontal"android:layout_alignParentBottom="true"android:layout_centerHorizontal="true"/><WebViewandroid:id="@+id/webview"android:layout_above="@+id/btnOk"android:layout_width="fill_parent"android:layout_height="fill_parent"
           /></RelativeLayout>

Post a Comment for "Android Layout Issue With Buttons Below Webview"