首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >背景相对布局

背景相对布局
EN

Stack Overflow用户
提问于 2014-02-27 20:54:10
回答 3查看 79关注 0票数 0

我会设置我的活动的背景。

这是我的布局(用列表视图填充)

代码语言:javascript
运行
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:background="#FFFFFF" >

    <TextView
        android:id="@+id/girone"
        style="@style/NomeSquadra"
        android:layout_width="fill_parent"
        android:layout_height="20dip" />

    <TextView
        android:id="@+id/home"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/girone"
        android:layout_marginLeft="2dip"
        android:gravity="left|center_vertical" />

    <TextView
        android:id="@+id/away"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/girone"
        android:layout_marginLeft="2dip"
        android:layout_toRightOf="@+id/vs"
        android:gravity="right|center_vertical" />

    <TextView
        android:id="@+id/vs"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_below="@+id/girone"
        android:layout_centerHorizontal="true"
        android:background="#0000FF"
        android:gravity="center|center_vertical" />

</RelativeLayout>

如果我写android:background="@drawable/logo" (到relativeLayout),图像logo.png没有缩放...我哪里错了?

EN

回答 3

Stack Overflow用户

发布于 2014-02-27 21:00:16

尝尝这个

代码语言:javascript
运行
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/logo"
     >
票数 1
EN

Stack Overflow用户

发布于 2014-02-27 20:56:33

android:layout_height属性添加到RelativeLayout xml,如下所示...

代码语言:javascript
运行
复制
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF" >

更新:

完美工作的XML布局...

代码语言:javascript
运行
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/logo" >

    <TextView
        android:id="@+id/girone"
        style="@style/NomeSquadra"
        android:layout_width="fill_parent"
        android:layout_height="20dip" />

    <TextView
        android:id="@+id/home"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/girone"
        android:layout_marginLeft="2dip"
        android:gravity="left|center_vertical" />

    <TextView
        android:id="@+id/away"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/girone"
        android:layout_marginLeft="2dip"
        android:layout_toRightOf="@+id/vs"
        android:gravity="right|center_vertical" />

    <TextView
        android:id="@+id/vs"
        style="@style/NomeSquadra"
        android:layout_width="wrap_content"
        android:layout_height="25dip"
        android:layout_below="@+id/girone"
        android:layout_centerHorizontal="true"
        android:background="#0000FF"
        android:gravity="center|center_vertical" />

</RelativeLayout>
票数 0
EN

Stack Overflow用户

发布于 2014-02-27 20:58:54

将高度添加到此布局的父级

代码语言:javascript
运行
复制
 android:layout_height="fill_parent"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22069148

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档