Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android overlay通过编程在顶部添加一个片段来滚动视图_Android_Android Layout_Android Fragments_Fragment_Scrollview - Fatal编程技术网

Android overlay通过编程在顶部添加一个片段来滚动视图

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

我正在做一个布局,我有一个“标题”,下面是一个滚动视图。在标题下面,我想添加另一个应该在scrollview顶部(即覆盖)绘制的片段。我目前有:

<?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);