2013-08-30 54 views
0

我是android新手,如何在不更改父主题的情况下以编程方式添加标题栏背景图像。我的应用程序基于标签主机。有两个选项卡。我想从标题栏中删除appname和app图标,并想添加背景图片。请帮忙。提前致谢。如何在android中以编程方式添加标题栏背景图像

回答

2

您可以infalte您的自定义布局,标题栏是这样的:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.your_custom_layout); 
+0

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); getWindow()。setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.your_custom_layout);它给出了错误:引用的部分还不存在:org.eclipse.ui.views.ProblemView – Ved

+0

是否确定你是否传递了存在的布局而不是这个R.layout.your_custom_layout? – Jilberta

+0

感谢您的帮助,我已经使用此代码解决了我的问题:Drawable d = getResources()。getDrawable(R.drawable.top_header); getActionBar()setBackgroundDrawable(d)。 – Ved

相关问题