Android標題列各種設定

來源:互聯網
上載者:User
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,是具有排它性的,一旦設定,後續不可更改為別的類型;

(3) 當使用TabHost(由ActivityGroup派生)時,各個Tab裡的Activity,要麼都是NO_TITLE,要麼都是CUSTOM_TITLE,無法分別進行設定。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.