设置程序无label
setcontentview前加上requestWindowFeature(Window.FEATURE_NO_TITLE);
??以下為轉載//未驗證
在實際的應用程序開發中,我們有時需要把 Activity 設置成全屏顯示,一般情況下,可以通過兩種方式來設置全屏顯示效果。其一,通過在代碼中可以設置,其二,通過manifest配置文件來設置全屏。
? ? ?其一:在代碼中設置(如下)
publicvoid onCreate(Bundle savedInstanceState) { ?
? ? ? ?super.onCreate(savedInstanceState); ?
//設置無標題
? ? ? ?requestWindowFeature(Window.FEATURE_NO_TITLE); ?
//設置全屏
? ? ? ?getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, ?
? ? ? ? ? ? ? ?WindowManager.LayoutParams.FLAG_FULLSCREEN); ?
? ? ? ?setContentView(R.layout.main); ?
} ?
? ? ? 但要注意的是:在代碼中設置的話,設置無標題和設置全屏的兩段代碼要放置在 setContentView(R.layout.main); 這段代碼的前面。要不然會報錯。
? ? ? 其二:在manifest配置文件中設置
<?xml version="1.0" encoding="utf-8"?> ?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
? ? ?package="com.andyidea"
? ? ?android:versionCode="1"
? ? ?android:versionName="1.0"> ?
? ?<uses-sdk android:minSdkVersion="8" /> ?
? ?<application android:icon="@drawable/icon" android:label="@string/app_name"> ?
? ? ? ?<activity android:name=".login.LoginActivity"
? ? ? ? ? ? ? ? ?android:theme="@android:style/android.NoTitleBar.Fullscreen"
? ? ? ? ? ? ? ? ?android:label="@string/app_name"> ?
? ? ? ? ? ?<intent-filter> ?
? ? ? ? ? ? ? ?<action android:name="android.intent.action.MAIN" /> ?
? ? ? ? ? ? ? ?<category android:name="android.intent.category.LAUNCHER" /> ?
? ? ? ? ? ?</intent-filter> ?
? ? ? ?</activity> ?
? ?</application> ?
</manifest> ?
? ? ? ?在相應的Activity中節點中添加屬性:android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 即可以設置某個Activity全屏顯示。若設置成 android:theme="@android:style/Theme.NoTitleBar" 即是只是設置成無標題狀態。
轉載于:https://blog.51cto.com/12575213/1167408
總結
以上是生活随笔為你收集整理的设置程序无label的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: win10最新进不了系统更新不了怎么办
- 下一篇: 大豆和黄豆芽还能吃吗?