android - 如何调整背景图像大小以适应Android中的应用程序屏幕尺寸

标签 android android-imageview

我使用的是 s4 Galaxy,我下载了以下壁纸 wallpaper http://www.sswallpaper.com/get/samsung-galaxy-s4-wallpapers/Keep-Running-1080x1920/595-2.jpg我尝试使用此壁纸作为背景图像,但该图像不适合我的屏幕。如何调整大小以适合我的应用程序的屏幕尺寸?

这是我的 Xml 代码:

      <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/walking" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="WELCOME"
        android:textSize="40dp"
        android:textColor="@color/textColor"
        android:textStyle="bold"
        android:typeface="serif"
        android:id="@+id/textView5"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="45dp" />

    <TextView
        android:layout_width="189dp"
        android:layout_height="50dp"
        android:text="SKIP"
        android:textSize="20dp"
        android:textColor="@color/textColor"
        android:textStyle="bold"
        android:typeface="serif"
        android:gravity="center"
        android:id="@+id/skip"
        android:onClick="click"
        android:clickable="true"
        android:layout_gravity="bottom"
        android:layout_alignParentBottom="true"
        android:layout_toStartOf="@+id/textView5" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="To skip the tutorial press SKIP at the bottom.Slide to the left to continue to tutorial page."
        android:id="@+id/textView3"
        android:textColor="@color/textColor"
        android:layout_below="@+id/textView5"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="90dp" />

</RelativeLayout>

我得到的图像的屏幕截图 screenshot

最佳答案

如果您不希望图像缩放......那么您应该使用..

android:scaleType="centerCrop"

编辑:

你应该使用FrameLayout来实现这种布局,就像这样......

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="centerCrop"
        android:src="@drawable/walking"/>

    <LinearLayout
        android:id="@+id/contentLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        .......

    </LinearLayout>

</FrameLayout>

关于android - 如何调整背景图像大小以适应Android中的应用程序屏幕尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34973661/

相关文章:

java - 如何让ImageView出现在圆内的随机位置?

android - 如何将 ImageView 中的图像与 ImageView 的底部对齐?

Android 从 ListView 和 SQLite 数据库中删除一个值

java - 使用compareTo增加应用程序版本名称

android - 如何将jar文件添加到构建路径

Android动态获取ImageView实际高宽

Android Sqlite 检查两个不同的列中是否存在两个值

java - 将字符串电话号码转换为整数

android - 图像位置无法使用刻度类型矩阵设置中心

java - 将图像数组传递到下一个屏幕