WebView in my app shows as window, but I want it be fullscreen! Here is screenshort of it:

Here is my code:
public class DockViewerActivity extends Activity {
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWebView = new WebView(this);
setContentView(mWebView);
mWebView.loadUrl("file:///android_asset/1.html");
Toast.makeText(this, getString(R.string.loading), Toast.LENGTH_LONG).show();
}
}
set the height and width to match_parent like below:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/conrainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webview"
android:layout_width="match_parent "
android:layout_height="match_parent "/>
</RelativeLayout>
to remove the status bar you have to use:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
to remove titlebar,you have to use:
requestWindowFeature(Window.FEATURE_NO_TITLE);
both of the above features you have to set before set your content view like below i am doing:
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.base_screen);
}
height, width to match_parent like:LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
mWebView .setLayoutParams(layoutParams);
and its done now!! #cheers!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With