如何让android应用程序屏幕全屏化?

如何让android应用程序屏幕全屏化?,android,android-layout,webview,android-webview,android-fullscreen,Android,Android Layout,Webview,Android Webview,Android Fullscreen,我正在android平台上制作一个浏览器应用程序。我正在安卓2.3版上测试我的应用程序。我面临的问题是,我无法使应用程序全屏显示。我希望“WebView”全屏显示,但应该看到通知栏。此外,标题栏应隐藏。 我试过使用这些: this.requestWindowFeature(Window.FEATURE_NO_TITLE); 但我仍然可以在我的应用程序中看到标题栏 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCRE

我正在android平台上制作一个浏览器应用程序。我正在安卓2.3版上测试我的应用程序。我面临的问题是,我无法使应用程序全屏显示。我希望“WebView”全屏显示,但应该看到通知栏。此外,标题栏应隐藏。 我试过使用这些:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
但我仍然可以在我的应用程序中看到标题栏

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
这会隐藏通知栏,但我不希望这样。我只想隐藏标题栏。我还尝试在清单文件中使用主题,例如:

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

但这样一来,我的应用程序不会启动,而是突然停止

我的webview和URL地址栏也显示在中间。他们在四面都留下了一些空间。这样地:

如何删除它使其全屏显示。
请提供帮助。

要禁用标题栏,请尝试将其添加到清单中-

android:theme="@android:style/Theme.NoTitleBar"
android:theme="@style/Theme.Transparent"
或者试试这个:

将此添加到样式中-

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

根据我的说法,
requestWindowFeature(Window.FEATURE\u NO\u TITLE)应该可以正常工作。只需在
setContentView(…)
之前添加一次,如下所示-

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

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(com.android.internal.R.layout.preference_list_content);
...
}
<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>

我不确定,但由于默认的页边距,您的WebView可能会留下空间。您的布局文件必须与此类似-

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

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(com.android.internal.R.layout.preference_list_content);
...
}
<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>

还要确保没有任何其他边距和填充,还要确保WebView的高度和宽度是
匹配\u parent

您的活动的父类类型是什么?当你们应用主题时,应用程序不启动是什么意思?它抛出异常?如果有,请发布异常信息。谢谢您的建议。但仍然存在一个问题。标题栏。它不会消失。我在setContentView之前键入了,但仍然无效。还有一件事,每当我试图改变主题时,我的应用程序就不会启动,而是意外停止。