国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

android全屏去掉title欄的多種實現方法

2020-04-11 12:31:45
字體:
來源:轉載
供稿:網友
1.實現應用中的所有activity都全屏
在manifest中直接加入
復制代碼 代碼如下:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

2.實現單個activity全屏
復制代碼 代碼如下:

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.TYPE_STATUS_BAR, WindowManager.LayoutParams.TYPE_STATUS_BAR);

3.實現單個activity去掉title欄
復制代碼 代碼如下:

requestWindowFeature(Window.FEATURE_NO_TITLE);

1、改變標題內容:public void setTitle (CharSequence title)
2、隱藏標題:requestWindowFeature(Window.FEATURE_NO_TITLE);
3、隱藏標題和最上面的電池電量及信號欄(全屏):
復制代碼 代碼如下:

public void setFullscreen() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

4、自定義標題內容
復制代碼 代碼如下:

<activity android:name=".activity.MainActivity" android:screenOrientation="portrait" android:label="@string/titlebar_text"
</actibity> 2)

MainActivity文件中:
復制代碼 代碼如下:

requestWindowFeature(Window.FEATURE_NO_TITLE);
//設置窗口無標題欄
setContentView(R.layout.main);
//動態設置標題的值,getTitle()的值是該activity的聲明中android:label的值
((TextView) findViewById(R.id.titlebar_text)).setText(getTitle());

其中,getTitle()取得的值就是上述 android:label="@string/titlebar_text" 的值
5、自定義標題布局
復制代碼 代碼如下:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//預先設置允許改變的窗口狀態,需在 setContentView 之前調用,否則設置標題時拋運行時錯誤。
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.custom_title);
//標題區域可設置為 layout ,如此可以有豐富的展現方式
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_title_1);
}

res/layout/custom_title_1.xml 包含一個TextView 用于顯示標題。Android可以把標題做為一個layout來展示,具有很好的擴展性。
復制代碼 代碼如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/screen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView android:id="@+id/left_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@string/custom_title_left" />
</RelativeLayout>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 静宁县| 开江县| 卓资县| 徐水县| 临海市| 锦屏县| 巫山县| 洞头县| 措美县| 太仓市| 西乌珠穆沁旗| 长乐市| 汶上县| 宜宾县| 洪泽县| 屏山县| 沭阳县| 稷山县| 会泽县| 饶平县| 安图县| 凭祥市| 奈曼旗| 怀仁县| 溧阳市| 万安县| 武平县| 福贡县| 金溪县| 车致| 西充县| 贡觉县| 敦煌市| 社旗县| 东海县| 龙陵县| 武威市| 武清区| 西华县| 襄城县| 浦东新区|