我看到很多关于通过传递null或new Drawable()到setBackgroundDrawable()来移除PopupWindow边框的问题。我遇到的问题恰恰相反。我想在我的PopupWindow周围添加一个边框,最好还带有指向锚点的工具提示箭头。目前,我的PopupWindow没有边框。我尝试调整边距、xml中的背景、布局、ListView和ListView行的宽度和高度,但都失败了。请问有人能帮我在顶部添加边框和图像吗?我想在此过程中坚持使用Android SDK。
popup_menu_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<com.github.jeremiemartinez.refreshlistview.RefreshListView
android:id="@+id/popup_menu_list_listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/color_white" />
</LinearLayout>
Java
private void displayPopupMenu() {
LayoutInflater layoutInflater = getLayoutInflater();
View popupView = layoutInflater.inflate(R.layout.popup_menu_list, null);
final PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
RefreshListView myListView = (RefreshListView) popupView.findViewById(R.id.popup_menu_list_listview);
mAdapter = new myAdapter(this, getAdapterData());
myListView.setAdapter(mAdapter);
popupWindow.showAsDropDown(mMyAnchor);
}
我只是拿这些作为示例,但我想要类似这样的东西,其中弹出窗口指向锚点:
但我得到了像这样的东西: