在方向改变时改变视图背景图像

发布于 2024-12-28 19:00:48 字数 157 浏览 1 评论 0原文

如果我有一个图形设计,比如说将 TextEdit 控件作为背景图像,那么从纵向视图更改为横向视图时是否可以拉伸图像?

我来自 WEB,使用 CSS,我可以将背景图片分为 3 部分,并使背景动态拉伸。在 android 环境中是否可能出现这样的情况,或者我应该为每个方向使用不同的布局?

If I got a graphic design for lets say a TextEdit control as a background image, is it possible to stretch the image when changing from portrait to landscape view?

I'm coming from WEB and with CSS where I could divide the background picture to 3 parts and make the background stretch dynamically. Is something like this possible in android environment or should I use different layouts for each orientation?

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

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

发布评论

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

评论(1

嘿咻 2025-01-04 19:00:48

您可以通过将不同的图形放入项目中 /res 目录的单独子文件夹中来声明它们。通过命名约定,您的应用程序将自动选择它们。

例如,如果您使用名为 textBackground.png 的背景图像,并且根据方向有两个版本。例如,应用程序默认情况下将使用 res/drawable/textbackground.png ,而在横向模式下则使用 res/drawable-land/textBackground.png

查看此文档以获取完整故事:

http://developer.android.com/guide/topics /resources/providing-resources.html

You can declare different graphics by dropping them in separate sub-folders of the /res directory in your project. By naming convention, your application will pick them up automatically.

For example, if you use a background image called textBackground.png and you have two versions of it depending on orientation. The app will use res/drawable/textbackground.png by default and res/drawable-land/textBackground.png when in landscape mode, for example.

Check out this doc for the full story:

http://developer.android.com/guide/topics/resources/providing-resources.html

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