在 Photoshop 中创建的自定义按钮的正确尺寸
我使用标准 UI 元素为我的应用程序创建了一个布局。现在我想在 Photoshop 中创建漂亮的按钮以获得更好的外观。所以我用 Button.getWidth() 和 getHeight() 检查了一个按钮的大小,因为我不希望按钮图像必须缩放并且它看起来像像素。但是,当我创建尺寸为我的按钮(例如 145x45)时,图像将在应用程序中缩放,看起来不太好! :-/
问题是什么。我怎样才能制作完全适合例如 ImageView 中的自定义按钮而无需缩放?
希望你能帮助我。
谢谢!
问候 Thomas
例如:
I created a Layout for my App with the standard UI-Elements. Now i want to create nice Buttons in Photoshop for a better look. So i checked the size for example one Button with Button.getWidth() and getHeight() because i don't want that the Button-Image had to be scaled and it looks pixel. But when i create the Button with the size i became, for example 145x45, the image will be scaled in the app and it looks not good! :-/
what is the problem. How can i make custom Buttons that fit exact for example in an ImageView without scaling?
Hope you can help me.
Thanks!
Greets
Thomas
For Example:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不要缩放按钮。创建九块图像,按钮在任何分辨率下都会看起来很棒:)
http:// /developer.android.com/guide/developing/tools/draw9patch.html
Do not scale the button. Create nine-patch image and the button will look great at any resolution :)
http://developer.android.com/guide/developing/tools/draw9patch.html
您可以将图像加载到宽度和高度为“wrap_content”的 ImageView 中,并处理 ImageView 的 onClicked 以将其用作 Button。
You can load the image in an ImageView with width and height to "wrap_content" and handle the onClicked of the ImageView to use it as a Button.
如果我正确理解你的话,它会对你有帮助。您已为按钮创建了高清 PNG,但它在您的设备上无法正常缩放。
解决方案:如果您创建了较大的按钮图像,然后将其放入XHDPI文件夹中,它可能看起来比以前小一些如果您想进一步缩小图像尺寸,请将其放入在 XXHDPI 或 XXXHDPI 中,它会很好地工作,您不需要创建 nine9patch 或其他任何内容。注意(请确保您要放入 XXHDPI 或 XXXHDPI 中的图像不应位于 PNG 的其他 drawable 文件夹中强> 应该只在任何一个文件夹中)
If I understand you correctly it will help you. You have created a High Defenition PNG for a button and it is not scaling proberly on your device.
Solution: If You have created a larger button image then put it in XHDPI folder it may look some what smaller than before else If you want to shrink the image size more put it in XXHDPI OR XXXHDPI which will work very nice you don't need to create nine9patch or anything else. note (Make sure that the image your going to put in XXHDPI OR XXXHDPI should not be in other drawable folder that PNG should be in any one folder only)