android - 缩放作为按钮背景的图像

标签 android image button

我有一个很大的按钮,我想设置一个图像作为它的背景。我希望它占按钮空间的 70%,中间有重力。

最佳答案

这样做的“好”方法是使用 9-Patch 图像:

http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

http://developer.android.com/reference/android/graphics/NinePatch.html

有一个可用的工具:

http://developer.android.com/guide/developing/tools/draw9patch.html

如果您想使用自己的图片,按钮会自动调整为图片的大小。

关于android - 缩放作为按钮背景的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8137956/

相关文章:

html - 翻转图像 - 仅在浏览器中

image - 我如何以编程方式删除重复的图像?在 magento

javascript - 使用 javascript/jquery 在一个函数中编写多个按钮

html - 按钮不会进入导航栏

Android:版本 21 未出现在 SDK 管理器中

android - 无法在android中相对布局的顶部和下方获得黑色 strip

带有 RecyclerView 的 Android BottomSheet

android - 如何从 android 微调器中的项目 ID 获取项目的位置?

python - 确定这个 RGB 元组是什么颜色

c# - WPF 拖放按钮