LHS of the following disagram shows the initial structure of the Activity
set up in XML, and the RHS shows the Activity
after some runtime changes.
The black border encloses the RelativeLayout
(I can change it to LinearLayout
or something else if that solves my problem) which is the root of the Activity's layout, the red border encloses a RecyclerView
, the green border inside it encloses an element of the RecyclerView. The dark blue border encloses a FrameLayout
to which a Fragment
will be added at runtime.
Now the thing is that at runtime, some more elements are added to the red bordered RecyclerView
, collectively shown by purple-bordered box in the RHS of the diagram. Only the part of the RecyclerView
containing these newly added elements should overlay the rest of the Activity
's content (i.e. essentially the FrameLayout
)
So what kind of layout should I use as the root of the Activity, how should I make this part-of-a-layout-overlapping-the-neighbours thingy possible? How should I go about it? Any suggestions will be greatly appreciated.
With RelativeLayout
, FrameLayout
and CoordinatorLayout
you can achieve overlap layout.
However it may need more details to know which is best for you.
Edit:
If the green layout is having fixed height, say, 100dp
, seems you could easily get what you want with RelativeLayout
<RelativeLayout>
<FrameLayout android:height="match_parent"
android:width="match_parent"
android:layout_marginTop="100dp"/>
<RecyclerView/>
</RelativeLayout>