Open nickdaugherty opened 12 years ago
There's no magic going on, you have to assign an already scaled icon to the action.
I see, thanks. Would be a nice feature if ActionBar auto scaled drawables to fit nicely.
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;
}
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.