Ashish
Ashish

Reputation: 388

How to make android app screen go full screen?

I am making a browser app on android platform. I am testing my app on 2.3 version of android. The problem which I am facing is, I am not able to make the app screen full screen. I want the "WebView" to take full screen, but notification bar should be seen. Also, the title bar should be hidden. I had tried using these :

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

But still I can see the title bar in my app.

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

This hides the notification bar, but I don't want that. I just want to hide the title bar. I had also tried using theme in Manifest file such as:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen

OR

android:theme="@android:style/Theme.Black.NoTitleBar

But with this, my app doesn't start.It stops abruptly.

Also my webview and URL address bar kind of displaying in center. They are leaving some space on all four sides. Like this: How to make a full screen webview

How to remove it make it full screen. Pls Help.

Upvotes: 1

Views: 1686

Answers (1)

Confuse
Confuse

Reputation: 5786

To disable Title bar, try adding this in Manifest -

android:theme="@android:style/Theme.NoTitleBar"

or try this:

Add this in styles -

<style name="Theme.Transparent" parent="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">"
    <item name="android:windowBackground">#000000</item>
</style>

and then set theme as this in Manifest -

android:theme="@style/Theme.Transparent"

According to me, requestWindowFeature(Window.FEATURE_NO_TITLE); should work fine. Just once try adding it before setContentView(...) like this -

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(com.android.internal.R.layout.preference_list_content);
...
}

I am not sure but probably your WebView is leaving space due to default margins. Your layout file must be somewhat like this -

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    //REMOVE THIS CODE
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    //TILL HERE

    tools:context="com.example.web.MainActivity" >

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"     //MAKE THIS MATCH_PARENT
        android:layout_height="match_parent"    //MAKE THIS MATCH_PARENT
        android:layout_alignParentBottom="true" />

    ...

</RelativeLayout>

Remove this -

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"

Also make sure you don't have any other margins and padding and also make sure WebView's height and Width is match_parent...

Upvotes: 1

Related Questions