2011-10-24 166 views
0

我有一个简单的布局,下面给出。我已经将父级(RelativeLayout)背景设置为图片,并且子表格布局设置为白色。出于某种原因,当我设置桌面布局的颜色时,它会使父布局变黑(或为空)。我不确定这里的问题是什么,如果我有线性布局而不是表格布局,情况也是如此。Android中的布局问题

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/mbi33" android:id="@+id/rl" android:clipToPadding="true"> 
<TableLayout android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:background="@color/white"> 
    <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content"> 
     <Button android:text="Button" android:layout_height="wrap_content" android:id="@+id/button1" android:layout_weight="1" android:layout_width="0dp"></Button> 
     <Button android:text="Button" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/button2" android:layout_width="0dp"></Button> 
     <Button android:layout_height="wrap_content" android:text="Button" android:id="@+id/button3" android:layout_weight="1" android:layout_width="0dp"></Button> 
    </TableRow> 
</TableLayout> 
</RelativeLayout> 

任何帮助,将不胜感激。

回答

0

更改

机器人:layout_width = “mach_parent” --->机器人:layout_width = “FILL_PARENT”

机器人:layout_height = “mach_parent” --->机器人:layout_height =“ FILL_PARENT”

它应该工作...

如果不是你可以试试这个添加这也太... 机器人: fillViewport =“true”

+0

我改变了相对布局的宽度和高度,它没有任何区别。 – vikramjb

+0

你可以评论行cliptoPadding,看看它会是什么。 – medampudi

1

您是否在colors.xml文件中指定了颜色? 如果您在位于文件夹中的colors.xml文件中指定了它,可以指定android:background =“@ color/white”。确保它已被指定。