Reputation: 723
Im trying to set a backgound to a RelativeLayout. The issue is that the layout is resized after the size of the image, which i don't want. I want the layout to be sized after the two textviews.
Anyway to prevent the layout to be scaled to the size of the background?
This is the xml-code
<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>
Regards
Upvotes: 0
Views: 1864
Reputation: 116412
I think all you need is to change android:layout_width="match_parent" into android:layout_width="wrap_content" for the relativeLayout, so that the sizes will be according to the textViews alone.
Why did you add android:layout_weight="1" ? is it only a part of your layout file?
if so, if it's in a vertical linearLayout, use:
android:layout_width="match_parent"
android:layout_height="0px"
and if it's in a horizontal linearLayout, use:
android:layout_width="wrap_content"
android:layout_height="0px"
Upvotes: 1