[英]How to make android app screen go full screen?
我在android平台上制作一個瀏覽器應用程序。 我正在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
要么
android:theme="@android:style/Theme.Black.NoTitleBar
但是這樣一來,我的應用程序無法啟動,突然停止了。
我的webview和URL地址欄也顯示在中心。 他們在所有四個方面都留有空間。 像這樣: 如何制作全屏網頁視圖
如何刪除它使其全屏顯示。 請幫助。
要禁用標題欄,請嘗試在清單中添加它-
android:theme="@android:style/Theme.NoTitleBar"
或嘗試以下方法:
以樣式添加此-
<style name="Theme.Transparent" parent="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">"
<item name="android:windowBackground">#000000</item>
</style>
然后在清單中將主題設置為此-
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
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.