I have an XML layout with some custom tabs, a heading, and a ProgressBar(main.xml). I wish to add another XML layout(home.xml) to the main.xml layout, as i wish to keep main.xml re-usable for other activity’s layouts and simply add things to it as necessary.
home.xml contains a ScrollView and a TextView. I am currently using my Activity’s LayoutInflator to add home.xml to main.xml:
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.home, rootLayout);
rootLayout is the root layout of main.xml and is a RelativeLayout
The problem: after inflating R.layout.home into rootLayout, it seems as though the ProgressBar contained in rootLayout is hidden underneath the content of home.xml
Is there a way to tell certain views(via XML) to float above other views when the layout is constructed in this way?
if not, am i forced to use methods such as progressBar.bringToFront() to raise targeted views to the top?
what alternatives do i have in z-ordering views when some layouts are constructed using inflation?
edit: it seems as though the bringToFront() method is not doing what i expect – i call it on one of my Button views and it still appears to be ordered below all other views(which were inflated) and remains unclickable
You could try using
ViewStubinstead of manually adding it and set the set theinflateIdwithsetInflateId(R.layout.home)http://developer.android.com/resources/articles/layout-tricks-stubs.html
Edit:
Google seem have to moved the android developer from their android page to blogspot.
Updated Link:
http://android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-with.html