相关疑难解决方法(0)

将自定义标题与FEATURE_PROGRESS组合在一起

在我的onCreate()中,我设置了一个进度条,如下所示:

getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
Run Code Online (Sandbox Code Playgroud)

现在,希望稍微增强标题栏,我想改变它的背景颜色.第一步是检查是否FEATURE_CUSTOM_TITLE支持:

final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
if ( customTitleSupported ) {
    Log.i(TAG, "CUSTOM TITLE SUPPORTED!")
}
Run Code Online (Sandbox Code Playgroud)

但是一旦我打电话给requestWindowFeature(Window.FEATURE_CUSTOM_TITLE)我得到一个:

AndroidRuntimeException: You cannot combine custom titles with other title features
Run Code Online (Sandbox Code Playgroud)

(如果我在设置之前FEATURE_PROGRESS或之后调用此函数无关紧要)

知道如何解决这个问题吗?

或者,如果我能找到非自定义标题栏的资源ID,我会避免使用定义标题栏.比危险的getParent()更好的东西.

这可能吗?

android android-layout android-titlebar

5
推荐指数
1
解决办法
1440
查看次数

标签 统计

android ×1

android-layout ×1

android-titlebar ×1