imageView没有拉伸以适应屏幕

Dhe*_*kar 5 android

我有一个drawable,需要作为背景.它需要拉伸才能填满屏幕(忽略纵横比).

我为ldpi,mdpi,hdpi和xhdpi提供了合适的大小.(我知道它们与相应的宽度和高度的比例是合适的,这还够吗?)

我试过这样做如下:

在imageView上使用scaleType:fitXY

这确实在imageView周围(内部?)留下了白色边距.

fitXY图像

我不满意的解决方法是使用scaleType中心,如下所示:

我不满意,因为平板电脑屏幕上仍然存在这个问题. 在此输入图像描述

注意:

  • 正如您可能已经注意到的那样,我已经在SO上的其他位置尝试了建议的修复,例如将Adjust View Boundaries设置为true.他们在这里没有帮助.:(
  • 我想要一个非程序化的答案/修复,就像在XML本身中这样做.我真的不想写代码来设置背景图像; 生活应该比这简单得多.(:P)

更新1:

这是XML布局

<merge xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" -->
    <!-- xmlns:tools="http://schemas.android.com/tools" -->
    <!-- android:id="@+id/FrameLayout1" -->
    <!-- android:layout_width="fill_parent" -->
    <!-- android:layout_height="fill_parent" -->
    <!-- tools:context=".SplashScreen" > -->


    <!--
         This FrameLayout insets its children based on system windows using
         android:fitsSystemWindows
    -->

    <View
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:onClick="onClickTapToContinue"
         >
    </View>

    <ImageView
        android:id="@+id/bg_gradient"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="fill"
        android:adjustViewBounds="true"
        android:contentDescription="@string/this_is_the_background_image"
        android:scaleType="center"
        android:src="@drawable/bg_gradient" />

    <ImageView
        android:id="@+id/bg_artwork"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:adjustViewBounds="true"
        android:contentDescription="@string/artwork_man"
        android:src="@drawable/bg_artwork" />

    <!-- </FrameLayout> -->

    <ImageView
        android:id="@+id/branding"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center|top"
        android:adjustViewBounds="true"
        android:contentDescription="@string/branding_text"
        android:maxHeight="95dp"
        android:paddingTop="5dp"
        android:src="@drawable/title_wlcm" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center"
        android:paddingBottom="5dp"
        android:text="@string/tap_continue"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="@android:color/white" />

</merge>
Run Code Online (Sandbox Code Playgroud)

Dhe*_*kar 1

我现在要进行的破解是按原样使用这些图像集用于手机,也许使用另一组图像(和布局?)用于 WVGA(平板电脑)。

不过还没有尝试过这个。我会尽快发布截图。

编辑:数字它与图像本身有关。有透明的填充物。会请设计师修复。:)