我将为您翻译以下内容:
我希望找到一种最佳方法,将.png图像用作应用程序主活动屏幕的背景。我希望它能在尽可能多的设备上适当地显示。
我现有的代码可以运行,但我想知道可移植性的最佳实践是什么。
这是我在XML中使用的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main_background"
android:padding="25dp"
>
...other stuff like a few buttons that go on top of background
当前文件"main_background.png"是一个800px x 600px的图像。我注意到在我的手机上至少水平尺寸会被缩小,从而扭曲图像。有没有一种理想的宽高比可以使我的背景图片更好?
谢谢。
match_parent
,然后使用LayoutParams
将高度设置为与宽度相同的值... - Jeeter