I wrote this code into my Activity and my logo displays, but it has a space before the logo
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.emenu_logo);
setTitle("");
Screenshot:
I don't know how to fix that, please help me!
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);
}
}