繁体   English   中英

如何在Android中使用指针创建自定义弹出菜单

[英]How to create custom popup menu with pointer in android

我想创建一个带有指针的弹出菜单,以显示在弹出窗口中显示的记录。

我试图从此链接自定义Dialog,但它不显示指针。

我想要的是下面的图片:

图片范例

像这样使用背景。

它应该工作

创建一个drawable.xml文件“ rectangle_shape.xml”

 <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android:fillColor="#FFFFFF" android:pathData=" M2,2 C2,2 2,1 3,1 L 21,1 C21,1 22,1 22,2 L 22,21 C22,21 22,22 21,22 L 14,22 L 12,24 L 10,22 C3,22 2,22 2,21 Z" android:strokeWidth="0.2" android:strokeColor="#dadada" /> </vector> 

创建一个布局文件,例如

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="250dp"> <RelativeLayout android:id="@+id/rlv1" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/rectangle_shape"> </RelativeLayout> </RelativeLayout> 

最后,在rlv1 relativelayout页面中放入您的代码,并修复是否出现边距问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM