Monday, 26 August 2013

Why is my RelativeLayout stretching the entire screen?

Why is my RelativeLayout stretching the entire screen?

I have a RelativeLayout defined as follows:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/message"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="@drawable/myDesign"
android:gravity="center"
android:padding="2dp"
android:text="@string/name"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
Here is what it looks like: http://i.imgur.com/nwutqi9.png
For some reason, RelativeLayout, extends the entire screen, even to the
black part. I tested out that the RelativeLayout extends the entire screen
by temporarily setting an onClickListener to the RelativeLayout (got it in
a Service through LayoutInflater then View, etc). When I set the
onClickListener (just for testing purposes) and clicked on the screen
blank (transparent) screen, it was also clickable. So I concluded that the
relativelayout extended the entire layout.

No comments:

Post a Comment