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

首頁 > 系統 > Android > 正文

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

2020-02-21 17:30:59
字體:
來源:轉載
供稿:網友

我們在開發項目的時候往往不需要系統本身的標題欄,而是要實現標題欄本身,這就需要去掉系統的標題欄,武林技術頻道小編和大家分享實現android全屏去掉title欄的方法。

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>

?實現android全屏去掉title欄的方法已經為各位朋友們介紹完畢了,大家看完之后,是不是掌握了呢?想學習更多知識,請繼續關注武林技術頻道!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴塘县| 泌阳县| 凌源市| 东阿县| 南川市| 闸北区| 宁陵县| 临夏县| 甘南县| 枣阳市| 鹤庆县| 富民县| 雅安市| 沾化县| 宿松县| 赞皇县| 永寿县| 贞丰县| 三门峡市| 枞阳县| 育儿| 孟村| 克什克腾旗| 玛沁县| 自贡市| 锡林浩特市| 扶余县| 抚远县| 富平县| 淳化县| 阿合奇县| 蒲江县| 庆城县| 靖安县| 乐至县| 淄博市| 介休市| 柳林县| 毕节市| 东阿县| 永德县|