Should android widget backgrounds be nine-patch? S

2019-08-12 21:03发布

At android.com's Widget Design Guidelines page, Google provide widget background templates in Photoshop format (.psd)

I know these can be edited and exported as png files, but I have two questions;

(a) should they be converted to nine-patch png files?

(b) Do I need to create different dpi versions (ldpi, mdpi, hdpi & xhdpi)?

I think the answers to both these questions are "Yes" but it is strange that this is not mentioned...

1条回答
等我变得足够好
2楼-- · 2019-08-12 21:19

From my personal experience: Yes to both.
Optimize for multiple screen sizes and densities as you would do with any other layout. That includes the choice which resource type is better for a certain situation, 9patches or different density-versions of a bitmap.

Concerning the documentation
I'm not 100% confident on this, but it seems to me this was written for Android 1.5. (since widgets were introduced in 1.5.) and never touched again since then. Support for different screen resolutions and densities came mostly in 1.6. - which changes everything mentioned in this widget doc. A good indicator to this is the fact that they give you exact pixel dimensions down below. This does make sense in 1.5., but not in 1.6. or newer. And therefore they don't cover the whole density-independence/resolutions idea.

查看更多
登录 后发表回答