android 带箭头提示框,Android PopupWindow与Tooltip箭头

博主正在寻找如何在PopupWindow中添加边框和一个指向锚点的提示箭头。当前问题在于,尽管尝试了修改布局、背景、边距等,PopupWindow仍然没有显示边框。目标是实现一个类似于工具提示的样式,但目前只得到了无边框的结果。希望找到解决方案以保持与Android SDK的兼容性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我看到很多关于通过传递null或新的Drawable()到setBackgroundDrawable()删除PopupWindow的边框的问题。我有相反的问题。我想在我的PopupWindow周围的边框,最好用一个工具提示箭头指向我的锚。目前,我的PopupWindow没有边框。我已经尝试调整边距,在xml中的背景,布局,列表视图和列表视图行的宽度和高度无效。有人可以帮助我得到一个边框和顶部的图像吗?我试图坚持与这个Android SDK。

popup_menu_list.xml

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:orientation="vertical" >

android:id="@+id/popup_menu_list_listview"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="@color/color_white" />

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

}

我只是抓住这些作为例子,但我想要这样的弹出指向锚点:

但我得到这样的东西:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值