Android編程設(shè)置全屏的方法實例詳解
本文實例講述了Android編程設(shè)置全屏的方法。分享給大家供大家參考,具體如下:
在實際的應(yīng)用程序開發(fā)中,我們有時需要把 Activity 設(shè)置成全屏顯示,一般情況下,可以通過兩種方式來設(shè)置全屏顯示效果。其一,通過在代碼中可以設(shè)置,其二,通過manifest配置文件來設(shè)置全屏。
其一:在代碼中設(shè)置(如下)
package xiaohang.zhimeng; import android.app.Activity; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class Activity01 extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //設(shè)置為無標(biāo)題欄 requestWindowFeature(Window.FEATURE_NO_TITLE); //設(shè)置為全屏模式 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //設(shè)置為橫屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentView(R.layout.main); } }
但要注意的是:在代碼中設(shè)置的話,設(shè)置無標(biāo)題和設(shè)置全屏的兩段代碼要放置在 setContentView(R.layout.main); 這段代碼的前面。要不然會報錯。
其二:在manifest配置文件中設(shè)置
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ladygaga.playboy" 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="com.ladygaga.test.ImageSwitcherTest" android:screenOrientation="sensor" 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>
或:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ladygaga.playboy" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:label="@string/app_name"> <activity android:name="com.ladygaga.test.ImageSwitcherTest" 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>
在相應(yīng)的Activity中節(jié)點中添加屬性:
希望本文所述對大家Android程序設(shè)計有所幫助。
- Android編程實現(xiàn)WebView自適應(yīng)全屏方法小結(jié)
- Android編程實現(xiàn)WebView全屏播放的方法(附源碼)
- android編程開發(fā)之全屏和退出全屏的實現(xiàn)方法
- Android中3種全屏方法及3種去掉標(biāo)題欄的方法
- Android設(shè)置全屏代碼分享
- Android下Activity全屏顯示實現(xiàn)方法
- android 設(shè)置全屏的兩種方法
- android屏幕全屏的實現(xiàn)代碼
- Android 設(shè)置應(yīng)用全屏的兩種解決方法
- android全屏去掉title欄的多種實現(xiàn)方法
- Android編程之界面實現(xiàn)全屏顯示的方法(2種方法)
相關(guān)文章
Android開發(fā)之Flutter與webview通信橋梁實現(xiàn)
這篇文章主要為大家介紹了Android開發(fā)之Flutter與webview通信橋梁實現(xiàn),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06Android TextView實現(xiàn)帶鏈接文字事件監(jiān)聽的三種常用方式示例
這篇文章主要介紹了Android TextView實現(xiàn)帶鏈接文字事件監(jiān)聽的方法,結(jié)合實例形式分析了鏈接跳轉(zhuǎn)、setMovementMethod及布局屬性設(shè)置三種常用的實現(xiàn)方式,需要的朋友可以參考下2017-08-08Android自定義View構(gòu)造函數(shù)詳解
這篇文章主要為大家詳細(xì)介紹了Android自定義View構(gòu)造函數(shù),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-10-10基于Android 實現(xiàn)圖片平移、縮放、旋轉(zhuǎn)同時進(jìn)行
這篇文章主要介紹了基于Android 實現(xiàn)圖片平移、縮放、旋轉(zhuǎn)同時進(jìn)行的相關(guān)資料,需要的朋友可以參考下2015-11-11