How to add imageview on right hand side of action bar?

后端 未结 5 1882
星月不相逢
星月不相逢 2021-01-30 05:53

I want to add image view on action bar right hand side.I tried to do that but i couldn\'t. Can anyone help me?

This is my image view xml

 

        
5条回答
  •  花落未央
    2021-01-30 06:05

    Use

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowCustomEnabled(true);
    
    LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.custom_imageview, null);
    
    actionBar.setCustomView(v);
    

    Code for Custom ImageView

    
    
    
    
    

提交回复
热议问题