Android標題欄各種設定

2021-06-16 12:20:49 字數 1201 閱讀 4184

1、隱藏標題欄

requestwindowfeature(window.feature_no_title);

2、在標題欄顯示進度條

requestwindowfeature(window.feature_progress);

setcontentview(r.layout.progressbar_1);

setprogressbarvisibility(true);

final progressbar progresshorizontal = (progressbar) findviewbyid(r.id.progress_horizontal);

setprogress(progresshorizontal.getprogress() * 100);

setsecondaryprogress(progresshorizontal.getsecondaryprogress() * 100);

3、使用自定義標題欄

requestwindowfeature(window.feature_custom_title);

setcontentview(r.layout.***);

getwindow().setfeatureint(window.feature_custom_title,r.layout.my_title_bar);

4、清除標題欄內容,而區域保留

((viewgroup) getwindow().findviewbyid(com.android.internal.r.id.title_container)).removeallviews();

5、隱藏標題欄

((viewgroup)getwindow().

findviewbyid(com.android.internal.r.id.title_container)).setvisibility(view.gone);

6、顯示標題欄

...setvisibility(view.visible);

其他注意事項

(1) requestwindowfeature()要在setcontentview()之前呼叫;

(2) 設定各種feature,是具有排它性的,一旦設定,後續不可更改為別的型別;

(3) 當使用tabhost(由activitygroup派生)時,各個tab裡的activity,要麼都是no_title,要麼都是custom_title,無法分別進行設定。

Android共用標題欄

首先建立乙個標題的布局檔案 然後建立這個布局檔案對應的class,這個class繼承linearlayout類,並且實現view.onclicklistener package com.example.administrator.uicustomview import android.content...

android去除標題欄

這是常用的幾種辦法 方法1 直接在activity的oncreate 方法中,requestwindowfeature window.feature no title 注意這句 要寫在,設定布局之前,不過這樣有個缺點只是在單個頁面的!方法2 在清單檔案中配置一下,將它預設的主題改為 android ...

Android去除標題欄

name concealtitle name android windownotitle true item style resources 再從menifest中引用 android theme style concealtitle android系統自帶樣式 android theme andr...