如何膨胀背后另有一个视图 [英] How to inflate a view behind another
问题描述
原谅我,如果这是一个简单的问题,但是我是新来的Android开发这个问题一直缠着我。
Forgive me if this is a simple question however I am new to Android Development and this problem has been bugging me.
我有包含的RelativeLayout和这个库com.devspark.sidenavigation.SideNavigationView一个基地布局文件。
I have a "base" layout file which contains a RelativeLayout and a com.devspark.sidenavigation.SideNavigationView from this library.
然后我有一个ViewPager其膨胀等布局(包括列表视图和progressBars)到这个活动。我的问题是,无论我尝试做的SideNavigationMenu总是出现膨胀的列表视图后面。我不知道发生了什么错,我在布局乱七八糟迷路。没有任何人有任何指针?
I then have an activity with a ViewPager which inflates other layouts (containing ListViews and progressBars) into this. My issue is that however I try and do it, the SideNavigationMenu always appears behind the inflated listviews. I'm not sure what's going wrong and I'm getting lost in a mess of Layouts. Does anyone have any pointers?
下面是我的基地布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".NewNews"
tools:ignore="MergeRootFrame">
<com.devspark.sidenavigation.SideNavigationView
android:id="@+id/side_navigation_view_news"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"/>
</RelativeLayout>
和它们充气的子-layouts之一的示例:
and an example of one of the "sub"-layouts which are inflated:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<eu.erikw.PullToRefreshListView
android:id="@+id/listView_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"/>
<ProgressBar
android:id="@+id/progressBar_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
在此先感谢
推荐答案
相对布局不支持层。
视图是通过它们被添加到布局的顺序放置在彼此的顶部。
Views are placed on top of each other by the order they are added to the layout.
例如。
- 添加到viewA的RelativeLayout
- 添加到viewB的RelativeLayout
- viewB将盈方viewA的
膨胀背后的膨胀,另一个是充气前的另一种观点的一种方式。
One way to inflate "behind" is inflating the other view before the other one is inflated.
- 添加到viewB的RelativeLayout
- 添加到viewA的RelativeLayout
- viewA将盈方viewB的
或删除视图,并重新添加到RelativeLayout的
or remove the view and re-add it to the relativelayout
- 添加到viewA的RelativeLayout
- 添加到viewB的RelativeLayout
- 删除viewA
- 重新添加viewA
- viewA将盈方viewB的
这篇关于如何膨胀背后另有一个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!