2013-03-26 76 views
0

我试图设置背景到RelativeLayout。 问题在于布局在图像大小之后调整大小,这是我不想要的。我希望布局在两个文本浏览后进行大小调整。防止布局调整后背景

无论如何,以防止布局缩放到背景的大小?

这是XML的代码

<RelativeLayout 
    android:id="@+id/hud" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@+drawable/hud_background" 
    android:layout_weight="1" > 

    <TextView 
     android:id="@+id/lblScore" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:text="Score: " /> 

    <TextView 
     android:id="@+id/txtScore" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignBaseline="@+id/lblScore" 
     android:layout_alignBottom="@+id/lblScore" 
     android:layout_toRightOf="@+id/lblScore" 
     android:text="00" /> 

</RelativeLayout> 

问候

+0

能否请您再字呢? “你的意思是”现在发生的图像大小之后,布局不应该调整大小?“ – yarian 2013-03-26 20:47:30

+0

希望它现在更清晰一点 – Fredkr 2013-03-26 20:54:41

+0

ouuh你的意思是相对布局高度应该是textview1高度+ textview2高度,无论背景图像大小..? – lelloman 2013-03-26 20:56:49

回答

1

我认为,所有你需要的是改变的android:layout_width = “match_parent” 成机器人:layout_width =为RelativeLayout的 “WRAP_CONTENT”,所以大小将根据textViews单独。

为什么添加android:layout_weight =“1”?它只是你的布局文件的一部分?

如果是这样,如果它在一个垂直的LinearLayout,用途:

android:layout_width="match_parent" 
android:layout_height="0px" 

,如果它是在一个水平LinearLayout中,使用:

android:layout_width="wrap_content" 
android:layout_height="0px" 
+0

是它的垂直线性布局的一部分,我只是想出了这一点以及:)谢谢! – Fredkr 2013-03-26 21:20:31