开发者

How can I add an image to the title bar in android 3.0?

I am learning android 3.0. Can any one tell How can add Image in Title bar in android 3.0? In developer site they are telling by default it will c开发者_开发知识库ome.but for me it is not coming. Thanks in advance.


You will have to create Custom Title Bar Layout to add your own image in titlebar.And then you can use following code to assign the titlebar to your view

    boolean customTitleSupported;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    if (customTitleSupported) {
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_tittlebar_layout);         

        }
        setContentView(R.layout.main);
   }  

here custom_tittlebar_layout refers to your custom titlebar layout with image.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜