Search code examples
androidwebviewandroid-actionbarfill-parent

Webview doesn't fit fullscreen with action bar on


I want to have webview displayed fullscreen with action bar on top of it and standard menu bar on bottom. It's displayed correctly without action bar. When I am turning it on, bottom part of webview is displayed under bottom menu bar and I want to fit it between both menu bars. Its probably easy fix but can't find answer on that. Thanks!

Code:

main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >


    <WebView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layerType="software"
       />

</RelativeLayout>

settings.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:id="@+id/group1">
        <item android:id="@+id/opt" android:android:showAsAction="ifRoom|withText" android:enabled="true" android:title="Option 1" android:visible="true"></item>
        <item android:id="@+id/opt2" android:showAsAction="ifRoom|withText" android:enabled="true" android:title="Option 2" android:visible="true"></item>

    </group>

</menu>

activity:

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.settings, menu);
    this.menu = menu;




    getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    return true;
}

Solution

  • Use Relative Layout in order to fit things in the right way.

    Show us more code in order to obtain for a better answer :D

    MOD

    Options menu is not made usually for fit into your layout , but overlapping it . I tell you to consider creating a fixed real menu which hides whenever you want with some action.

    Also think that menu can't have a fixed size and it may change with orientation , mobile phone , android version . Then if you could made what you need , you'll have more problems with your layout than making a custom one.