ActionBarSherlock - remove the app icon in the action view (and other design issues)

I just started using ActionBarSherlock and I am having some small styling issues. I don't want the application icon to be displayed on the left side and this is easily achieved with

getSupportActionBar().setDisplayShowHomeEnabled(false);

      

However, in one of the activities, I want to have a collapsible activity view (search view). When I set SearchView as an activity view and drill into it, the application icon appears again. Do you know how to get rid of it?

And another problem is the divider between the buttons, how can I set the drawable?

Any help would be appreciated!

+3


source to share


3 answers


Well, I found a workaround for the icon problem, but I don't really like it. There must be a distance to make him go away together in search mode ...

For now, I just set the transparent color as the icon:



getSupportActionBar().setIcon(android.R.color.transparent);

      

Look for the best ideas though!

+20


source


This is how I was able to fully customize it actionbarsherlock

with my custom layout.

In your Activity

(which is spreading SherlockFragmentActivity

),

mActionBar = getSherlock().getActionBar();
mActionBar.setDisplayShowCustomEnabled(true);
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.setDisplayUseLogoEnabled(false);
mActionBar.setDisplayHomeAsUpEnabled(false);
mActionBar.setDisplayShowHomeEnabled(false);
// provide zero dimen drawable for logo icon
mActionBar.setIcon(R.drawable.zero_dimen_icon);

LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 
Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
// provide your custom layout here
mActionBar.setCustomView(inflater.inflate(R.layout.action_bar_content, null),lp);

      

In your picture folder



drawout / zero_dimen_icon.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <size
        android:height="0dp"
        android:width="0dp" >
    </size>

    <solid android:color="#00000000" >
    </solid>

</shape>

      

Works for me, even with split action bar.

+4


source


try it

  ActionBar ab = getSupportActionBar();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    /*  adding action bar on top  */
    ab.setDisplayShowHomeEnabled(true);              
    ab.setDisplayShowTitleEnabled(true);
    ab.setTitle("your title");

      

0


source







All Articles