I
I
Igor2015-05-04 20:06:06
Android
Igor, 2015-05-04 20:06:06

How to remove space on the left side of ActionBarSherlock (see screenshot)?

Appears on API version 21 (5.0.0) in API version 16 (4.1.1) everything is ok.
I use ActionBarSherlock 4.4.0, I prescribe a Custom View for the top bar, I don’t need all the other default elements:

activity.getActionBar().setHomeButtonEnabled(false); // disable the button
activity.getActionBar().setDisplayHomeAsUpEnabled(false); // remove the left caret
activity.getActionBar().setDisplayShowHomeEnabled(false); // remove the icon

activity.getActionBar().setCustomView(R.layout.action_bar_add_car);
activity.getActionBar().setDisplayShowCustomEnabled(true);

Does not help, the strip on the right remains.
Tried to add:
View homeIcon = activity.findViewById(android.R.id.home);
if (homeIcon != null) {
   ((View) homeIcon.getParent()).setLayoutParams(new LinearLayout.LayoutParams(0, 0));
   ((View) homeIcon).setVisibility(View.GONE);
}

the bar on the right has become smaller (see screenshot), but still there.
21e7f577dde74c18b7654233c1835f1e.png
How to remove, any ideas?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
z0rgoyok, 2015-05-04
@asdf999

Use AppCompat as written here https://github.com/JakeWharton/ActionBarSherlock

A
afeozzz, 2015-05-04
@afeozzz

Try like this

View v = getActionBar().getCustomView();
LayoutParams lp = v.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
v.setLayoutParams(lp);

T
Tiberal, 2015-05-05
@Tiberal

For an ordinary action bar, there is such a property,
try it, it might help

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question