Android标题栏各种设置
2016-03-16 10:48
381 查看
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,无法分别进行设置。
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,无法分别进行设置。
相关文章推荐
- Android编程实现修改标题栏位置使其居中的方法
- Android实现隐藏状态栏和标题栏
- wince禁止程序标题栏上的退出按钮示例
- JavaScript实现标题栏文字轮播效果代码
- JavaScript在浏览器标题栏上显示当前日期和时间的方法
- Android实现透明度可变的标题栏效果
- Android中自定义标题栏样式的两种方法
- 3种Android隐藏顶部状态栏及标题栏的方法
- js实现的标题栏新消息闪烁提示效果
- JavaScript实现在标题栏上显示当前日期的方法
- Android实现自定义标题栏的方法
- Android编程实现获取标题栏、状态栏的高度、屏幕大小及模拟Home键的方法
- iOS 5 cocos2d 游戏开发 3ff8 实战:第4章 你的第一个游戏
- 7月国外最新技术文章翻译汇总(IT技术)
- windows phone 8 的新特性
- 使用Html5开发Android和iOS应用:HBuilder、Html5Plus、MUI
- 2016年Bus365移动部门的年会节目-三句半
- Titanium 快速入门
- Titanium 用户界面之布局结构及核心代码块
- Android中的手势交互