You need something like this
<RelativeLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView (or android.support.v7.widget.RecyclerView)
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
And then to add the view do something like
RelativeLayout container = (RelativeLayout) findViewById(R.id.container);
int vId = 1234;
View v = makeControllerView();
v.setId(vId);
RelativeLayout.LayoutParams vParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
vParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
container.addView(v, vParams);
RelativeLayout.LayoutParams lvParams =
(RelativeLayout.LayoutParams) container.getLayoutParams();
lvParams.addRule(RelativeLayout.ABOVE, vId);
ListView lv = (ListView) findViewById(R.id.listview);
lv.setLayoutParams(lvParams);
I haven't tested this and have no idea if it works, but it is just to give you an idea of how it could be handled. This is not how I would handle this, if I knew there was the possibility of a view being added in this situation I would just add the view to the xml's layout and handle it's visibility. This is just since you asked.