Activity{
onCreate(){
getWindow().requestFeature(Window.No_TITLE);
}
}在这个Activity里初始化已经不要title了,但是我希望当用户点击网页链接的时候显示标题栏
从而用于显示网页的加载进度
该如何实现啊getWindow().requestFeature(Window.No_TITLE);这种控制title的语句据说只能在setContentView之前使用
onCreate(){
getWindow().requestFeature(Window.No_TITLE);
}
}在这个Activity里初始化已经不要title了,但是我希望当用户点击网页链接的时候显示标题栏
从而用于显示网页的加载进度
该如何实现啊getWindow().requestFeature(Window.No_TITLE);这种控制title的语句据说只能在setContentView之前使用
1.继续用getWindow().requestFeature(Window.No_TITLE) , 在你的activity的xml中做一个假的titlebar,用的时候显示,不用的时候visiblility设置成gone。
2.用getWindow().requestFeature(Window.FEATURE_CUSTOM_TITLE) 用法与第一种一样,需要是的时候visible 不需要时 gone
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,无法分别进行设置
{
public void onProgressChanged(WebView view, int progress)
{
this.setTitle("Loading...");
this.setProgress(progress * 100);
if(progress == 100)
this.setTitle(R.string.app_name);
}
}
);
这是我网页进度同步到title进度条的代码
你表达什么?
将WebView 定义到titlebar的xml里,在onCreate()里findviewByid找到这个webView 然后在你的title进度条的代码里传入找到的webView。
两种方法都能实现呀
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // 声明使用自定义标题
setContentView(R.layout.title);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);// 自定义布局赋值