Android 在不同的屏幕上,背景图像不失真/拉伸的最佳方式是什么?

Android 在不同的屏幕上,背景图像不失真/拉伸的最佳方式是什么?,android,android-2.1-eclair,Android,Android 2.1 Eclair,我想在我的活动背景中放置一个图像。此图像实际上是一个半透明的圆形徽标,应该位于UI上任何其他内容的后面。我还会将其偏移到下角 在不同的屏幕尺寸下,我放置此图像而不使其“挤压”(蛋形)的最佳方式是什么?我的应用程序将仅在纵向模式下运行 这就是我想要实现的目标: 到目前为止,我已经将我的圆形图像放置在3个白色矩形画布上,用于流行尺寸的屏幕480x854、320x480和240x320,这似乎可行,但我认为它不是很牢固 有什么建议吗?这可能不是完美的解决方案,需要对UI进行一些维护,但我的想法是:

我想在我的活动背景中放置一个图像。此图像实际上是一个半透明的圆形徽标,应该位于UI上任何其他内容的后面。我还会将其偏移到下角

在不同的屏幕尺寸下,我放置此图像而不使其“挤压”(蛋形)的最佳方式是什么?我的应用程序将仅在纵向模式下运行

这就是我想要实现的目标:

到目前为止,我已经将我的圆形图像放置在3个白色矩形画布上,用于流行尺寸的屏幕
480x854
320x480
240x320
,这似乎可行,但我认为它不是很牢固


有什么建议吗?

这可能不是完美的解决方案,需要对UI进行一些维护,但我的想法是:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_marginRight="-15dp"
        android:layout_marginBottom="-15dp"
        android:src="@drawable/circle"
        />
    <!--Rest of Layout goes here-->
</FrameLayout>

只需将其环绕在当前布局上,并将右侧和底部的边距调整为偏移所需的任何负边距。这应该适用于任何屏幕大小,假设您有每个密度的绘图


编辑:是的,你也不必担心这样的白色矩形。只需将
android:background
标记添加到FrameLayout中,使用您想要的任何颜色作为背景,并将徽标保存为透明PNG。

我会这样做,使用一个相对布局在背景中创建一个ImageView,其上是一个包含布局其余部分的相对布局

通过这种方式,图像尽可能大,以保持正确的尺寸

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:scaleType="centerInside"
        android:src="@drawable/splash_picture"/>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal">
        <!-- rest of your layout -->
    </LinearLayout>
</RelativeLayout>

可能重复:谢谢,您的解决方案适合我,而不是使用两次版面宽度;)