开发者

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

开发者 https://www.devze.com 2023-03-02 01:05 出处:网络
I am learning android 3.0. Can any one tell How can add Image in Title bar in android 3.0? In developersite they are telling by default it will c开发者_开发知识库ome.but for me it is not coming.

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

精彩评论

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