johannilsson / android-actionbar

DEPRECATED Android Action Bar Implementation
1.3k stars 564 forks source link

Item drawables too large #43

Open nickdaugherty opened 12 years ago

nickdaugherty commented 12 years ago

The action bar item drawable icons are all appearing full height/width for me (they stretch to fill the height of the actionbar), rather than the smaller image with padding that is seen in the example.

Is this an xml thing? I took the code from the example nearly verbatim.

johannilsson commented 12 years ago

There's no magic going on, you have to assign an already scaled icon to the action.

nickdaugherty commented 12 years ago

I see, thanks. Would be a nice feature if ActionBar auto scaled drawables to fit nicely.

GuyWhoCodez commented 11 years ago

SOLVED:

Go to ActionBar.java in the library and change the inflateAction function to this:

private View inflateAction(Action action) { View view = mInflater.inflate(R.layout.actionbar_item, mActionsView, false);

    ImageButton labelView =
        (ImageButton) view.findViewById(R.id.actionbar_item);
    Drawable dr = getResources().getDrawable(action.getDrawable());
    dr.setBounds(labelView.getLeft(), labelView.getTop(), labelView.getRight(), labelView.getBottom());
    labelView.setBackgroundDrawable(dr);

    view.setTag(action);
    view.setOnClickListener(this);
    return view;
}