对 Android 的搜索栏/进度栏使用可缩放位图

发布于 2024-09-27 22:43:46 字数 100 浏览 4 评论 0原文

我正在尝试为搜索栏创建自定义外观,并为正常/填充和拇指状态创建图像。但问题是图像没有被 android 缩放,而是只是平铺/裁剪。如何让 Android 缩放给定的图像而不是平铺/剪切?

I am trying to create a custom look for the seekbar, and I created images for normal/filled and the thumb states. But the problem is that the images are not being scaled by android, instead are just tiled/clipped. How can I ask Android to scale the given images instead of tiling/clipping?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我是有多爱你 2024-10-04 22:43:46

您可以使用java代码来缩放位图图像。

  • 将位图作为流读取
  • Bitmap bm = BitmapFactory.decodeStream(your buffered in put stream);
  • bm=bm.createScaledBitmap(bm,imgwidth,imgheight,new Boolean(false));

You can use java code to scale Bitmap images.

  • Read bitmap as stream
  • Bitmap bm = BitmapFactory.decodeStream(your buffered in put stream);
  • bm=bm.createScaledBitmap(bm,imgwidth,imgheight,new Boolean(false));
烟燃烟灭 2024-10-04 22:43:46

您不能要求 Android 为您执行此操作。

图像必须按照您将使用的尺寸创建。

You cannot ask Android to do this for you.

The images must be created in the size(s) you will be using them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文