Issue with RelativeLayout when View visibility is View.GONE Issue with RelativeLayout when View visibility is View.GONE android android

Issue with RelativeLayout when View visibility is View.GONE


You can use this tag:

android:layout_alignWithParentIfMissing="true"

From the docs:

If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc.


You can place textview 2 and 3 in the LinearLayout and keep the linear layout below textview 1.


why not update the below attribute of TextView3 when you update the visibility of TextView2? (I assume you do this in code)

something like

TextView tv = (TextView) findViewById(R.id.textview3);RelativeLayout.LayoutParams lp =    (RelativeLayout.LayoutParams) tv.getLayoutParams();lp.addRule(RelativeLayout.BELOW, R.id.textview1);((TextView) view).setLayoutParams(lp);