Is it possible to show the first view in a LinearLayout overlapping the second?
I would like to layout my views like so:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentRight="true" >
<TextView
android:id="@+id/firstTextView"
android:layout_width="wrap_content"
android:layout_height="wrapContent" />
<TextView
android:id="@+id/secondTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
But I need my first view from the layout, firstTextView, to be placed on top of (overlapping) secondTextView. Is this possible? I am using the LinearLayout because I'm also playing with the margins to get an overlapping effect.
If all you want is to overlap the two views vertically, then use this XML:
What worked for me and probably will work for you is that:
So the layout can be something like this:
and:
Or you can stick with Linear Layout, but place a RelativeLayout within it, as a child. You can than place your TextViews withing the RelativeLayout, so they'll inheret properties from RelativeLayout. You can then still use your LinearLayout for other views. http://developer.android.com/reference/android/widget/RelativeLayout.html
By assigning margin value "<0" we can overlap the views. But Relative layout is preferable when we need o overlap views.