Android標題欄的各種設置

Android標題欄的各種設置


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.xxx);
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,是具有排它性的,一旦設置,後續不可更改爲別的類型;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章