如何在Android中调整背景图片大小以适合应用程序屏幕大小 [英] How to adjust background image size to fit the app screen size in android

查看:112
本文介绍了如何在Android中调整背景图片大小以适合应用程序屏幕大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用s4星系,并且下载了以下壁纸

I am using a s4 galaxy and I downloaded the following wallpaper wallpaper http://www.sswallpaper.com/get/samsung-galaxy-s4-wallpapers/Keep-Running-1080x1920/595-2.jpg I trying to use this wallpaper as the background image but the image does not fit into my screen. How do I adjust the size to fit the screen size of my app?

这是我的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 of the Image I getting

推荐答案

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

If you don't want your image to scale.....then you should use..

android:scaleType="centerCrop"

您应该将FrameLayout用于这种布局,像这样...

you should use FrameLayout for this kind of Layout, like this...

<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中调整背景图片大小以适合应用程序屏幕大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆