Lee*_*Lee 50 android popupwindow
我已经看到很多关于通过将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)
我只是抓住这些作为例子,但我想要这样的东西弹出指向锚点:

但我得到这样的东西:

M D*_*M D 56
市场上有许多图书馆和代码.链接如下:
这是QuickAction UI模式.看一眼:
另一种选择是"超级工具提示":
https://github.com/nhaarman/supertooltips
这是一个演示:
https://play.google.com/store/apps/details?id=com.haarman.supertooltips
从第一个链接/示例看起来像下面的图像.这些只是演示,但您可以根据您的要求进行自定义.

Dou*_*ior 13
如果您正在寻找一个简单的库,我创建了一个基于PopupWindow的库.
https://github.com/douglasjunior/android-simple-tooltip

小智 5
您可以简单地将 PopupWindow 与带有矢量背景的视图一起使用:
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="20dp"
android:viewportHeight="162"
android:viewportWidth="196">
<path
android:fillColor="@color/black"
android:pathData="M0 26.9917C0 12.0846 12.09433 0 26.99583 0L169.0042 0C183.9136 0 196 12.09104 196 26.9917L196 100.0083C196 114.9154 183.9057 127 169.0042 127L124 127L98.5 162L73 127L26.99583 127C12.08644 127 0 114.909 0 100.0083L0 26.9917" />
</vector>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
81670 次 |
| 最近记录: |