Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 用于填充不同设备屏幕宽度的图像视图_Android_Android Imageview - Fatal编程技术网

Android 用于填充不同设备屏幕宽度的图像视图

Android 用于填充不同设备屏幕宽度的图像视图,android,android-imageview,Android,Android Imageview,我试图让我的应用程序在不同的设备上看起来很好。我在Galaxy S2和Google Nexus 7上试过。我的图像覆盖了S2上的宽度,但不完全覆盖Nexus上的宽度。为什么?我做错了什么 以下是my ImageView的代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativeLayout" android:orientati

我试图让我的应用程序在不同的设备上看起来很好。我在Galaxy S2和Google Nexus 7上试过。我的图像覆盖了S2上的宽度,但不完全覆盖Nexus上的宽度。为什么?我做错了什么

以下是my ImageView的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <include
        android:id="@+id/include"
        layout="@layout/actionbar"/>

    <ImageView
        android:id="@+id/imageView1"
        android:layout_height="match_parent"
        android:layout_width="fill_parent"
        android:layout_marginTop="44dp"
        android:src="@drawable/rect"/>

</RelativeLayout>


尝试将
ImageView的宽度和高度设置为
fill\u parent
设置ImageView的scaletype属性

尝试此-->



是的,但当我这样做时,我的图像视图会跳到屏幕中间吗?它被放置在一个相对布局中。请确保RelativeLayout设置为fill\u parent Too将有助于查看您的整个布局。请注意,
fill\u parent
已被弃用,您应该改用
match\u parent
。是的,我知道,如果您想为所有新旧版本的Android开发应用程序,请使用
fill\u parent
<ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="44dp"
    android:scaleType="fitXY"
    android:src="@drawable/rect"/>