Android - 自定义图像作为应用程序背景
我正在尝试使用已导入到drawable-mdpi文件夹中的png文件作为背景。但是,当我尝试在模拟器中运行我的应用程序时,仅通过 main.xml 将其设置为背景会导致进程意外停止。
将 png 文件设置为 main.xml 中的背景后,是否需要遵循任何分步过程(我还在下面包含了我的values/theme.xml)
values/theme.xml
<resources>
<style name="Theme.NoBackground" parent="android:Theme">
<item name="android:windowBackground">@drawable/pioneer_lift</item>
<item name="android:textColor">#000000</item>
</style>
</resources>
感谢您的帮助
I am attempting to us a png file that I have imported into the drawable-mdpi folder as my background. however, just setting it as the background through main.xml results in the process stopping unexpectedly when I attempt to run my app in the emulator.
Is there any step by step process I need to follow after setting the png file as the background in main.xml (I have also included my values/theme.xml below)
values/theme.xml
<resources>
<style name="Theme.NoBackground" parent="android:Theme">
<item name="android:windowBackground">@drawable/pioneer_lift</item>
<item name="android:textColor">#000000</item>
</style>
</resources>
Thanks for the help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将其设置为窗口背景,则无需将其也设置为布局的背景。 (没有理由让系统绘制两次 - 它会变慢。)
您是否将自定义主题设置为清单中的活动主题?
If you're setting this as a window background you don't need to set it as a background for your layout too. (No reason to have the system draw it twice - it will be slower.)
Have you set your custom theme as your Activity's theme in your manifest?