我有一个固定到文本视图的弹出窗口
popUpWindow.showAsDropDown(textView, final_placement_width, final_placement_height);
当我向下滚动时,TextView将随弹出窗口一起向上移动。
问题是如果我向下滚动太多,PopUp窗口不仅会显示内容窗口的顶部,而且还会将自身重新定位到底部的新滚动视图。
如何设置弹出窗口,使其无论我滚动多远,它都将保持在TextView数字1的顶部和紫色内容窗口的后面。
编辑:XML文件: activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.testapp.test.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
内容主要xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.testapp.test.MainActivity"
tools:showIn="@layout/activity_main">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/appOptions"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>