我正在使用API 16 (Jellybean),4.0 WVGA (480x800: hdpi)
我试图在背景中设置一个480x800图像
我把一个图像放在“drawable hdpi”中,但是这个图像不适合背景,为什么当我使用4.0 WVGA (480x800: hdpi)并且与图像大小相同时,这个图像不适合背景。
如何绘制适合图像的工作方式:
这是我的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.newapp.Firstscreen$PlaceholderFragment" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/background" />
</RelativeLayout>见截图:
http://s15.postimg.org/u8rkm6rhn/frghfghfgh.png
发布于 2014-03-20 09:44:39
你可以这样做
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.newapp.Firstscreen$PlaceholderFragment" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_paren"
android:layout_height="match_paren"
android:scaleType="fitXY"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/background" />
</RelativeLayout>或
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/background"
tools:context="com.example.newapp.Firstscreen$PlaceholderFragment" >
<!-- CONTENT HERE -->
</RelativeLayout>https://stackoverflow.com/questions/22528851
复制相似问题