My Logo doesn't display at the correct position in actionbar

后端 未结 1 1621
庸人自扰
庸人自扰 2020-12-18 16:08

I wrote this code into my Activity and my logo displays, but it has a space before the logo

getSupportActionBar().setDisplayUseLogoEnabled(true);
    getSupp         


        
相关标签:
1条回答
  • 2020-12-18 16:43

    Make a layout and inflate in your custom action bar...

    public class MainActivity extends Activity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        ActionBar mActionBar = getActionBar();
        mActionBar.setDisplayShowHomeEnabled(false);
        mActionBar.setDisplayShowTitleEnabled(false);
        mActionBar.setDisplayHomeAsUpEnabled(false);
        mActionBar.setDisplayUseLogoEnabled(false);
        LayoutInflater mInflater = LayoutInflater.from(this);
        View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);   // inflate layout file
    
        /// TextView,ImageView,Button  etc element 
    
        mActionBar.setCustomView(mCustomView);
        mActionBar.setDisplayShowCustomEnabled(true);
        mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
       }
    }
    
    0 讨论(0)
提交回复
热议问题