Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Action bar being shown below its tabs

When i set these attributes:

    actionBar = getSupportActionBar();

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle("Title");
    actionBar.setLogo(null);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

The ActionBar is below its Tabs.

But if i comment this Like:

actionBar.setDisplayShowHomeEnabled(false);

It works fine. But the reason i want it to be false is, to avoid the appIcon being shown.

Thank You

like image 525
Archie.bpgc Avatar asked Dec 07 '12 09:12

Archie.bpgc


2 Answers

I googled this problem and found this thread on gitub: https://github.com/JakeWharton/ActionBarSherlock/issues/327

You can read the thread, but the conclusion is:

Hi. Just found a simple workaround.

Use the following in your onCreate method :
View homeIcon = findViewById(android.R.id.home);
((View) homeIcon.getParent()).setVisibility(View.GONE);
this collapses the home button completely.

PS : i'm using standard ActionBar but this should work the same

I hope this helps you out,
Daniel.

like image 166
Dion Segijn Avatar answered Nov 15 '22 19:11

Dion Segijn


i used this, and it's work on me

    ActionBar ab = getSupportActionBar();
    ab.setDisplayShowHomeEnabled(true);
    ab.setDisplayHomeAsUpEnabled(false);
    ab.setHomeButtonEnabled(false);
    ab.setLogo(null);

    View homeIcon = findViewById(
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? 
            android.R.id.home : R.id.abs__home);
    ((View) homeIcon.getParent()).setVisibility(View.GONE);
    ((View) homeIcon).setVisibility(View.GONE);

    ab.setDisplayShowTitleEnabled(false);
like image 20
Fahriyal Afif Avatar answered Nov 15 '22 19:11

Fahriyal Afif