Android的背景图像,以填补屏幕 [英] Android background Image to fill screen

查看:157
本文介绍了Android的背景图像,以填补屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何得到我的亲戚布局,以显示我这样的图像视图:

取而代之的是

我想我的布局以显示尽可能多的图像,因为它可以和裁剪图像,的外侧,当你设置图片为背景桌面窗口中的填充,如:

我的XML布局至今:

 < XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent机器人:fitsSystemWindows =真正的机器人:alwaysDrawnWithCache =假>

    < ImageView的
        机器人:ID =@ + ID / imageView1
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignParentLeft =真
        机器人:layout_alignParentTop =真正的机器人:SRC =@可绘制/ background_race_light/>

    <的LinearLayout
        机器人:ID =@ + ID / linearLayout1
        风格=@风格/ SessionResumeBar
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT>

        <的TextView
            机器人:ID =@ + ID / home_resumeSessionBar_text
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_weight =1
            机器人:文本=中文字
            机器人:textAppearance =机器人:ATTR / textAppearanceMedium/>

        <按钮
            机器人:ID =@ + ID / home_resumeSessionBar_buttonResume
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:文本=简历/>
    < / LinearLayout中>





< / RelativeLayout的>
 

解决方案

添加一个规模型到你的ImageView。有几种类型。你需要的是

 安卓scaleType =中心
 

页面将有助于解释各种不同类型的。

How do I get my relative layout to display my image view like this:

Instead of this?:

I want my layout to display as much of the image as it can and crop the outsides of the image, like when you're setting desktop background image to "Fill" in windows:

My xml layout so far:

<?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:fitsSystemWindows="true" android:alwaysDrawnWithCache="false">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" android:src="@drawable/background_race_light"/>

    <LinearLayout
        android:id="@+id/linearLayout1"
        style="@style/SessionResumeBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/home_resumeSessionBar_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <Button
            android:id="@+id/home_resumeSessionBar_buttonResume"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Resume" />
    </LinearLayout>





</RelativeLayout>

解决方案

Add a scale type to your imageview. There are several types. The one you need is

android:scaleType="center"

This page will help explain all the different types.

这篇关于Android的背景图像,以填补屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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