Android 用于填充不同设备屏幕宽度的图像视图
我试图让我的应用程序在不同的设备上看起来很好。我在Galaxy S2和Google Nexus 7上试过。我的图像覆盖了S2上的宽度,但不完全覆盖Nexus上的宽度。为什么?我做错了什么 以下是my ImageView的代码: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
<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"/>