忙了断时间,终于闲了下来.也一直没有来iteye。最近在弄Ios和Wp,我会陆续发博的。


介绍下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,是具有排它性的,一旦设置,后续不可更改为别的类型;
(3) 当使用TabHost(由ActivityGroup派生)时,各个Tab里的Activity,要么都是NO_TITLE,要么都是CUSTOM_TITLE,无法分别进行设置。

更多相关文章

  1. Android(安卓)studio使用Lottie- 让Android动画实现更简单
  2. 类似HTML map标签功能的Android组件
  3. Android(安卓)studio 下拉刷新,加载更多使用LoadingViewFinal
  4. android中LayoutParams设置参数的理解
  5. android 自定义dialog,窗口动画
  6. EditText的光标选择(android.text.Selection)&输入指定字符
  7. 箭头函数的基础使用
  8. NPM 和webpack 的基础使用
  9. Python list sort方法的具体使用

随机推荐

  1. mysql恢复报ERROR 2006 (HY000) at line
  2. Linux Centos 下使用yum 命令安装mysql
  3. 从具有外部约束的多个表中删除
  4. Mysql异常_01_ 誓死登进mysql_Can't
  5. qt连接mysql运行时出现QSqlQuery::exec:d
  6. 【Qt】Qt5.12连接MySQl5.7(亲自测试成功)
  7. MySQL DELETE语句和TRUNCATE TABLE语句的
  8. 计算mysql中每天的发生次数
  9. 为获得快速结果,我的查询有什么好的索引?
  10. 读《SQL优化核心思想》:你不知道的优化技