Android 隱藏標題欄和全屏示例含代碼

    Android 隱藏標題欄和全屏示例

    在這個示例中,我們將解釋如何隱藏標題欄以及如何在全屏模式下顯示內容。愛掏網 - it200.com

    需要調用Activity的 requestWindowFeature(Window.FEATURE_NO_TITLE) 方法來隱藏標題。愛掏網 - it200.com但是,它必須在setContentView方法之前編碼。愛掏網 - it200.com

    隱藏Activity標題欄的代碼

    使用 getSupportActionBar() 方法來檢索ActionBar類的實例。愛掏網 - it200.com調用ActionBar類的hide()方法隱藏標題欄。愛掏網 - it200.com

    requestWindowFeature(Window.FEATURE_NO_TITLE);//will hide the title 
    getSupportActionBar().hide(); //hide the title bar
    

    啟用全屏模式的代碼

    Window類的 setFlags() 方法用于在全屏模式下顯示內容。愛掏網 - it200.com您需要在setFlags方法中傳遞 WindowManager.LayoutParams.FLAG_FULLSCREEN 常量。愛掏網 - it200.com

    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                   WindowManager.LayoutParams.FLAG_FULLSCREEN); //show the activity in full screen
    

    Android隱藏標題欄和全屏示例

    讓我們看一下在安卓中隱藏標題欄的完整代碼。愛掏網 - it200.com

    activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>  
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"  
        xmlns:app="http://schemas.android.com/apk/res-auto"  
        xmlns:tools="http://schemas.android.com/tools"  
        android:layout_width="match_parent"  
        android:layout_height="match_parent"  
        tools:context="first.javatpoint.com.hidetitlebar.MainActivity">  
    
        <TextView  
            android:layout_width="wrap_content"  
            android:layout_height="wrap_content"  
            android:text="Hello World!"  
            app:layout_constraintBottom_toBottomOf="parent"  
            app:layout_constraintLeft_toLeftOf="parent"  
            app:layout_constraintRight_toRightOf="parent"  
            app:layout_constraintTop_toTopOf="parent" />  
    
    </android.support.constraint.ConstraintLayout>  
    

    Activity類

    package first.javatpoint.com.hidetitlebar;
    
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.Window;
    import android.view.WindowManager;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE); //will hide the title 
            getSupportActionBar().hide(); // hide the title bar
            this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                   WindowManager.LayoutParams.FLAG_FULLSCREEN); //enable full screen
            setContentView(R.layout.activity_main);
    
    
        }
    }
    

    輸出:僅隱藏標題

    輸出:隱藏標題欄并啟用全屏模式

    聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。
    發表評論
    更多 網友評論0 條評論)
    暫無評論

    返回頂部

    主站蜘蛛池模板: 无码人妻精品一区二区蜜桃网站| 无码人妻一区二区三区免费手机| 亚洲国产一区二区三区青草影视| 亚洲AV乱码一区二区三区林ゆな| 亚洲高清一区二区三区| 精品在线一区二区| 久久精品一区二区三区不卡| 亚无码乱人伦一区二区| 亚洲av午夜福利精品一区人妖| 美女免费视频一区二区三区| 一区二区三区无码被窝影院| 国产一区二区中文字幕| 国产激情无码一区二区三区| 精品国产精品久久一区免费式 | 日韩在线视频一区二区三区| 久久久精品人妻一区亚美研究所| 精品一区二区91| 无码人妻精品一区二区三区9厂| 99久久人妻精品免费一区| 久久精品一区二区| 麻豆AV一区二区三区久久| 无码人妻AⅤ一区二区三区| 91久久精一区二区三区大全| 动漫精品一区二区三区3d| 国模精品一区二区三区视频| 亚洲丶国产丶欧美一区二区三区| 97精品国产一区二区三区| 久久99精品波多结衣一区| 国内偷窥一区二区三区视频| 一区二区三区影院| 免费av一区二区三区| 制服丝袜一区二区三区| 精品一区二区在线观看| 久久一区二区明星换脸| 91一区二区在线观看精品| 亚洲一区二区三区亚瑟| 亚洲AV一区二区三区四区| 国产福利无码一区在线| 亚洲第一区精品日韩在线播放| 一区二区三区视频免费观看| 国产AV国片精品一区二区|