简体   繁体   English

什么时候我应该在android中使用9补丁图像

[英]When should I use 9 patch image in android

Please help me to understand on when i have to make decision to define 9 patch image. 请帮我理解何时我必须决定定义9个补丁图像。 what i have understood is, 9-patch image is require only when i have defined my layout width and height with definite size but actually i don't have image of that size. 我所理解的是,9补丁图像只有在我定义了我的布局宽度和高度与确定的大小但实际上我没有那个大小的图像时才需要。 let's say, i have set background size as 300*100 in my layout definition. 比方说,我在布局定义中将背景大小设置为300 * 100。 but image i have 200*100, which is lesser size then what i need. 但是图像我有200 * 100,这比我需要的尺寸小。 in this case if i do define 9 patch image, will help to fit properly without compressing quality in all devices. 在这种情况下,如果我确定了9个补丁图像,将有助于在不压缩所有设备的质量的情况下正确安装。

This where i used to 9 patch. 这里我习惯了9补丁。

Now, what i want to understand is, does 9 patch image will scales on different screen resolution even if i have defined our layout definition as wrap content, match parent with no explicit value on width and height. 现在,我想要理解的是,即使我已经将我们的布局定义定义为包装内容,9个补丁图像将在不同的屏幕分辨率上缩放,匹配父级在宽度和高度上没有明确的值。 does 9-patch will scale based on screen resolution? 9-patch会根据屏幕分辨率进行缩放吗?

What are exactly nine patch - 究竟有九个补丁 -
The 9-Patch is a modified PNG image that allows Android to determine how the image can be stretched to meet the specific layout during runtime(like fill_parent and wrap_content). 9-Patch是一个经过修改的PNG图像,允许Android确定如何在运行时拉伸图像以满足特定布局(如fill_parent和wrap_content)。

Common Usege - 共同用途 -
1. Button backgrounds. 1.按钮背景。 (Default Android gray Button is a Nine-Patch) (默认Android灰色按钮是九个补丁)
2. Page backgrounds. 2.页面背景。
3. Splash screens. 3.飞溅屏幕。

Step-by-Step guides- 循序渐进的指南 -
1. Edit NinePatch in Android Studio . 1.在Android Studio中编辑NinePatch。
2. Best practice design usage here . 2. 这里的最佳实践设计用法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM