Android Action Bar: Can I replace a custom Title in appcompat v7

后端 未结 3 1730
逝去的感伤
逝去的感伤 2021-01-21 04:05

I want to add a custom action title on the left of the actin bar, replacing with the default title just like in the below image the default image is shown

3条回答
  •  Happy的楠姐
    2021-01-21 04:32

    You need to use the following code to get this:

    private ActionBar actionBar;
    
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            actionBar = getActionBar();
            actionBar.setTitle("");
            actionBar.setLogo(R.drawable.logo); //logo needs to be defined in the drawables folder.
    }
    

提交回复
热议问题