一区二区日本_久久久久久久国产精品_无码国模国产在线观看_久久99深爱久久99精品_亚洲一区二区三区四区五区午夜_日本在线观看一区二区

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 條評論)
暫無評論

返回頂部

主站蜘蛛池模板: 国产免费一区 | 日本精品视频一区二区 | 欧美成人一区二免费视频软件 | 国产一区二区精 | 国产精品不卡视频 | 一二区视频 | 国产精品久久久久久久久免费高清 | 无码一区二区三区视频 | 综合久久99| 欧美日韩一区二区三区四区 | 久久精品国产免费高清 | 一区二区在线 | 欧美激情精品久久久久久变态 | 中文字幕一区二区三区在线观看 | 久久一 | 成人深夜福利 | 国产欧美精品一区二区色综合 | 欧美精| 日本在线一区二区 | 久久99精品久久久久久国产越南 | 精品一区在线 | 久久久久久亚洲 | 亚洲精品视频一区二区三区 | 久久精品一级 | 在线国产欧美 | 91精品一区二区三区久久久久 | 999久久久久久久久6666 | 精品一区国产 | 中文字幕不卡在线观看 | 色秀网站 | 仙人掌旅馆在线观看 | www久久av| 国产农村妇女毛片精品久久麻豆 | 一本色道精品久久一区二区三区 | 国产精品免费观看 | 日韩精品在线看 | 中文字幕日韩欧美一区二区三区 | 一级欧美黄色片 | 午夜激情视频 | 国产日产精品一区二区三区四区 | www.日韩 |