介绍下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、显示标题栏

((ViewGroup)getWindow().findViewById(com.android.internal.R.id.title_container))                   .setVisibility(View.VISIBLE);


其他注意事项
(1) requestWindowFeature()要在setContentView()之前调用;
(2) 设置各种Feature,是具有排它性的,一旦设置,后续不可更改为别的类型;
(3) 当使用TabHost(由ActivityGroup派生)时,各个Tab里的Activity,要么都是NO_TITLE,要么都是CUSTOM_TITLE,无法分别进行设置。


更多相关文章

  1. android中,handler处理信息中弹出提示框注意事项
  2. Android上使调用OpenCV 2.4.10 实现二维码区域定位(Z-xing 码)
  3. android画图--切割区域
  4. Android中fragment注意事项
  5. Android 性能优化 之谈谈Java内存区域
  6. J2ME项目移植到Android平台六大注意事项
  7. Android 应用程序发布流程注意事项(整理)
  8. android使用volley等网络资源请求时注意事项(*)

随机推荐

  1. achartengine在Android中ScrollView组件
  2. 修改Android工程版本
  3. 【Android TextView/EditText 不允许换行
  4. Unity打包到android中屏蔽权限弹窗
  5. 为什么说Android令人沮丧!?
  6. Android 渗透测试学习手册 第七章 不太知
  7. Android彻底退出应用程序(转)
  8. 有关Android手机软件详细分析
  9. 基于Android 平台简易即时通讯的研究与设
  10. Android系列教程(3):Android SDK中常用命令