在我们的Android应用程序的启动活动中,我们使用带有背景图像的线性布局用于整个空间。
图像尺寸为320x480 - 与设备分辨率相同,我们用于测试。
问题是,图像会缩放,看起来不太好。
我尝试使用imageview,但我有黑色边框。
一些想法,如何避免缩放或如何获得适当的背景图像大小?!
提前谢谢。
穆尔。
答案 0 :(得分:34)
在res / drawable中创建background.xml文件并使用以下命令:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/background_image"
android:gravity="center"/>
并使用此background.xml作为LinearLayout的背景。