Android overlay通过编程在顶部添加一个片段来滚动视图
我正在做一个布局,我有一个“标题”,下面是一个滚动视图。在标题下面,我想添加另一个应该在scrollview顶部(即覆盖)绘制的片段。我目前有:Android overlay通过编程在顶部添加一个片段来滚动视图,android,android-layout,android-fragments,fragment,scrollview,Android,Android Layout,Android Fragments,Fragment,Scrollview,我正在做一个布局,我有一个“标题”,下面是一个滚动视图。在标题下面,我想添加另一个应该在scrollview顶部(即覆盖)绘制的片段。我目前有: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:la
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/fragment_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_below="@+id/fragment_container"
android:background="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Content -->
</ScrollView>
</RelativeLayout>
当然,这并没有达到我想要做的。我可以在我的初始片段容器下面添加另一个容器视图,让它成为覆盖。但我更喜欢把一切都放在一个片段内。有可能吗?我想你需要做的是这样的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/fragment_container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/overlay_view"
android:layout_below="@+id/fragment_container"
android:layout_width="match_parent"
android:visibility="invisible"
android:layout_height="wrap_content" />
<ScrollView
android:layout_below="@+id/overlay_view"
android:background="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Content -->
</ScrollView>
</RelativeLayout>
LinearLayout overlay_view = (LinearLayout) findViewById(R.id.overlay_view);
overlay_view.setVisibility(View.VISIBLE);