Add a view to the XML format programmatically and make its z-image below the existing view

I have an XML layout with some custom tabs, a header and ProgressBar( main.xml). I want to add another XML layout ( home.xml) to the layout main.xml, since I want to save main.xmlreusable activity for other layouts and just add things to it as needed.

home.xmlcontains a ScrollViewand a TextView. I am currently using my activity LayoutInflatorto add home.xmlto main.xml:

LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.home, rootLayout);

rootLayoutis the root location main.xmland isRelativeLayout

Problem: after bloating R.layout.homein, rootLayoutit seems that what ProgressBaris contained in rootLayoutis hidden under the contenthome.xml

Is there a way to let certain views (via XML) float over other views when the layout is designed this way?

If not, am I forced to use methods such as progressBar.bringToFront()to raise the target views at the top?

What alternatives do I have in z-order representations when some layouts are built using inflation?

edit: the method bringToFront()does not seem to fulfill what I expect - I find it in one of my views Buttonand it still looks ordered below all the other views (which were overpriced) and remains unclickable

+3
source share
2 answers

. , 0 ( , , Gallery), , - 1 . bringToFront() . , (, LinearLayout, 0 - 1 .)

+5

Source: https://habr.com/ru/post/1768640/


All Articles