在方向改变时改变视图背景图像
如果我有一个图形设计,比如说将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将不同的图形放入项目中 /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 andres/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