亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

android全屏去掉title欄的多種實(shí)現(xiàn)方法

 更新時(shí)間:2013年02月18日 09:48:17   作者:  
android全屏去掉title欄包括以下幾個(gè)部分:實(shí)現(xiàn)應(yīng)用中的所有activity都全屏/實(shí)現(xiàn)單個(gè)activity全屏/實(shí)現(xiàn)單個(gè)activity去掉title欄/自定義標(biāo)題內(nèi)容/自定義標(biāo)題布局等等感興趣的可參考下啊
1.實(shí)現(xiàn)應(yīng)用中的所有activity都全屏
在manifest中直接加入
復(fù)制代碼 代碼如下:

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

2.實(shí)現(xiàn)單個(gè)activity全屏
復(fù)制代碼 代碼如下:

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

3.實(shí)現(xiàn)單個(gè)activity去掉title欄
復(fù)制代碼 代碼如下:

requestWindowFeature(Window.FEATURE_NO_TITLE);

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

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

4、自定義標(biāo)題內(nèi)容
復(fù)制代碼 代碼如下:

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

MainActivity文件中:
復(fù)制代碼 代碼如下:

requestWindowFeature(Window.FEATURE_NO_TITLE);
//設(shè)置窗口無(wú)標(biāo)題欄
setContentView(R.layout.main);
//動(dòng)態(tài)設(shè)置標(biāo)題的值,getTitle()的值是該activity的聲明中android:label的值
((TextView) findViewById(R.id.titlebar_text)).setText(getTitle());

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

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//預(yù)先設(shè)置允許改變的窗口狀態(tài),需在 setContentView 之前調(diào)用,否則設(shè)置標(biāo)題時(shí)拋運(yùn)行時(shí)錯(cuò)誤。
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.custom_title);
//標(biāo)題區(qū)域可設(shè)置為 layout ,如此可以有豐富的展現(xiàn)方式
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_title_1);
}

res\layout\custom_title_1.xml 包含一個(gè)TextView 用于顯示標(biāo)題。Android可以把標(biāo)題做為一個(gè)layout來(lái)展示,具有很好的擴(kuò)展性。
復(fù)制代碼 代碼如下:

<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>

相關(guān)文章

最新評(píng)論