As my code below shows, I've two ImageView that I would like to overlap but the bigger is systematically put below the smaller one, both is android:layout_alignParentTop set "true", I thought that would lead to an overlapping but Android keeps dislaying them one below the other.
<RelativeLayout android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_horizontal|center_vertical">
<ImageView android:id="@+id/homeStars" android:src="@drawable/background"
android:layout_height="wrap_content" android:layout_width="fill_parent" android:scaleType="centerInside"
android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_alignParentTop="true"
/>
<ImageView android:id="@+id/homeLogo" android:src="@drawable/logo"
android:layout_height="wrap_content" android:layout_width="220dip"
android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
android:paddingTop="2dip" />
</RelativeLayout>
N开发者_如何学Pythonota 1 : I do not want the first one to be set as a background of the relative view. Nota 2 : I should add that this Relative Layout is put inside a ScrollView.
<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/homeStars"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerInside"
android:src="@drawable/background" />
<ImageView
android:id="@+id/homeLogo"
android:layout_width="220dip"
android:layout_height="wrap_content"
android:paddingTop="2dip"
android:src="@drawable/logo" />
</RelativeLayout>
I removed all of you're different layout_* tags and it works fine. Naturally all children will overlap each other by positioning themselves at the top left in a RelativeLayout
. You're extra tags were confusing not only me but likely the parser. Copy paste the above code and make changes incrementally next time! :)
Try this related post. A FrameLayout will get the job done, even though you seem very keen on a RelativeLayout. Is a compromise possible for you?
精彩评论