1

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

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

但我仍然可以在我的应用程序中看到标题栏。

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

这隐藏了通知栏,但我不希望这样。我只想隐藏标题栏。我还尝试在 Manifest 文件中使用主题,例如:

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

或者

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

但是有了这个,我的应用程序没有启动。它突然停止。

我的 webview 和 URL 地址栏也显示在中心。他们在所有四个方面都留下了一些空间。像这样: 如何制作全屏网页视图

如何删除它使其全屏。请帮忙。

4

1 回答 1

1

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

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

或试试这个:

在样式中添加这个 -

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

然后在 Manifest 中将主题设置为 -

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

据我所知,requestWindowFeature(Window.FEATURE_NO_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);
...
}

我不确定,但由于默认边距,您的 WebView 可能会留下空间。您的布局文件必须有点像这样 -

<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>

删除这个 -

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

还要确保你没有任何其他边距和填充,并确保 WebView 的高度和宽度是match_parent......

于 2014-10-12T02:43:26.653 回答