我已经看到很多关于通过将null或新的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>
Run Code Online (Sandbox Code Playgroud)
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);
}
Run Code Online (Sandbox Code Playgroud)
我只是抓住这些作为例子,但我想要这样的东西弹出指向锚点:

但我得到这样的东西:

我已经打了一个Activity电话Accounts,我想添加一个横向ContextMenu.这可能看起来像剪切,复制和粘贴选项.有没有办法onLongClick在列表项上添加这个水平自定义菜单?
这是我到目前为止所得到的.
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
LayoutInflater inflater = getLayoutInflater().from(this);
View view = inflater.inflate(R.layout.custom_listview, null, false);
menu.setHeaderView(view);
menu.add("Delete");
menu.add("Edit");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
int position = info.position;
View v = listView.getChildAt(position);
TextView typeTv = v.findViewById(R.id.custom_listview_type);
TextView userTv = v.findViewById(R.id.custom_listview_user);
TextView passTv = v.findViewById(R.id.custom_listview_password);
if (item.getTitle().equals("Delete")) {
db.execSQL("delete from user_added_accounts where accountType = '" + typeTv.getText().toString() …Run Code Online (Sandbox Code Playgroud)