Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item drawables too large #43

Open
nickdaugherty opened this issue Nov 29, 2011 · 3 comments
Open

Item drawables too large #43

nickdaugherty opened this issue Nov 29, 2011 · 3 comments

Comments

@nickdaugherty
Copy link

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
Copy link
Owner

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

@nickdaugherty
Copy link
Author

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

@GuyWhoCodez
Copy link

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants