imageView没有拉伸以适应屏幕

时间:2013-01-04 20:31:04

标签: android

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

我为ldpi,mdpi,hdpi和xhdpi提供了合适的尺寸。 (我知道它们对应宽度和高度的比例是否合适,是否足够?)

我试过这样做:

在imageView上使用scaleType:fitXY

  

这会在imageView。(/ p>)周围留下一个白色边缘(内部?)

fitXY image

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

我不满意,因为问题仍存在于平板电脑屏幕上。 enter image description here

注意:

  • 您可能已经注意到,我已经在其他地方尝试了建议的修复程序 在SO上设置调整视图边界为真。他们没有帮助 这里。 :(
  • 我想要一个非程序化的答案/修复,就像在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>

3 个答案:

答案 0 :(得分:1)

我现在要进行的黑客攻击是将这些图像用于手机,也可能是WVGA(平板电脑)的另一组图像(和布局?)。

  

虽然还没试过。我会尽快发布截图   做。

编辑:数字与图像本身有关。有透明填充。将要求设计师修复它。 :)

答案 1 :(得分:1)

使用android:background =“...”属性,而不是使用android:src =“...”。希望它有效。

答案 2 :(得分:0)

在eclipse活动的图形布局中,您可以右键单击活动,然后选择“编辑背景”。这将允许您将图片设置为背景,覆盖屏幕的所有边缘。 希望这会有所帮助,为吉姆喝彩。

相关问题