Domanda

I am trying to set custom view on ActionBar in android, My code is given below:

        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        getSupportActionBar().setDisplayShowCustomEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayUseLogoEnabled(false);

        LayoutInflater inflator = (LayoutInflater) this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflator.inflate(R.layout.custom_actionbar_layout, null);

        getSupportActionBar().setCustomView(v);

I want to show only custom view, here i attached screen shot of issue of overlapping.enter image description here

È stato utile?

Soluzione

just use this code

ActionBar actionBar = getSupportActionBar();
// add the custom view to the action bar
actionBar.setCustomView(R.layout.actionbar_view);

or can view detailed discussion HERE

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top