png
png

Reputation: 4408

android : how to make a webview fullscreen programatically

I have a webview pat of my activity layout I have a button "fullscreen" On clicking this i want the webview to occupy the full screen.

I have tried elativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT); webview.setLayoutParams(params);

But with this, 1. the button "fullscreen" that is specified to be aligned to bottom is still visible

  1. how can i get the minimised view back , If i click "back" arrow it goes to previous activity

Is there any other way to get full screen dynamically

Upvotes: 0

Views: 1164

Answers (1)

Franziskus Karsunke
Franziskus Karsunke

Reputation: 5208

If you press the Fullscreen Button, just remove the Button from the main view group. Now you have to overwrite the onKeyPressed and the onBackPressed method to make Android not go back to the previous Activity and make the Button visible again.

@Override
public void onBackPressed() {
    ... 
}   

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        ...
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}

Upvotes: 1

Related Questions