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

Bug: Icons are blurry in grid view #114

Open
ajhuntsman opened this issue Apr 14, 2016 · 4 comments
Open

Bug: Icons are blurry in grid view #114

ajhuntsman opened this issue Apr 14, 2016 · 4 comments

Comments

@ajhuntsman
Copy link

We're using Material Design icons from the Google library, at 48dp.

When using list style, the icons look great.

When using grid style, the icons are blurry on various tablets, but not on phones. I get the same result whether I build the Bottom sheet using items defined in a menu XML file, or dynamically from code (using enum values).

Overview
blurry_icons_overview

Up Close
blurry_icons_magnified

Should @style/BottomSheet_GridItemImage just use wrap_content for layout_width and layout_height instead of explicitly specifying 48dp?

@ajhuntsman
Copy link
Author

ajhuntsman commented Apr 20, 2016

I was able to successfully work around this by switching my drawables from PNG to Vector.

First, assuming your using 2.0 or higher of the Android Gradle plugin, modify build.gradle:

android {
    defaultConfig {
        vectorDrawables.useSupportLibrary = true
    }
}

Second, use Vector Asset Studio (within Android Studio 2.0+) to create a new vector XML resource, typically by importing a Material Design icon. For example, I created ic_assignment_black_24dp.xml

Third, if you're obtaining the Drawable icon from code (I'm building my bottom sheet from an enum, on the fly), get your Drawable icon as a vector using the AppCompatDrawableManager library:

Drawable actionIcon = AppCompatDrawableManager.get().getDrawable(view.getContext(), R.drawable.ic_assignment_black_24dp);

In this screen shot (Google Nexus 7 4.3 on Genymotion), the "List" icon is a vector drawable, but the others are PNG (all 5 densities). You can really taste the difference:
blurry_icon_comparison

@soarcn
Copy link
Owner

soarcn commented Apr 26, 2016

I myself always use vector drawable instead of bitmap in my projects.

The only reason of the blurry icon could be the resolution of the drawable resources, I would suggest you check whether the right bitmap resources been prepared and picked up (xxhdpi or xxxhdpi, not quite sure)

@ajhuntsman
Copy link
Author

Yeah, I had all 5 resolutions of each icon in place, and I even re-created new ones from scratch to verify. But now that I switched to vectors, it's a non-issue.

@waiinaythulay234
Copy link

Thank you for feedback

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