android弹出式菜单(效果爆炸)
发布日期:2021-05-08 04:55:04 浏览次数:18 分类:精选文章

本文共 1989 字,大约阅读时间需要 6 分钟。

有没有觉得常见的弹出菜单都很丑,常见的上下文菜单也很难看,当弹出一个菜单提供功能的时候,整个一点效果都没有。显得很突兀。 下面介绍一个菜单。重写了popupwindow 。效果图如下。 github地址

图片

话不多说上代码:
public class PathPopupWindow extends PopupWindow {       private final int CONST_R = 100;//圆半径    private final int CONST_ICON_SIZE = 35;    private Context context;    private FrameLayout frameLayout;    private ImageView imageView;    private View view_circle;    private List
itemViews = new ArrayList
(); private int itempadding = 0; private OnPathItemClickListener mOnPathItemClickListener; public void setOnPathItemClickListener(OnPathItemClickListener mOnPathItemClickListener){ this.mOnPathItemClickListener = mOnPathItemClickListener; } protected PathPopupWindow() { } public PathPopupWindow(Context context, List
items) { this(context,items, Color.BLACK,12, Color.TRANSPARENT); } public PathPopupWindow(Context context, List
items, int textColor, int textSize, int itembgResId) { super(context); this.context = context; setFocusable(true); itempadding = DensityUtil.dip2px(context, 8); int itemWidth = DensityUtil.dip2px(context,CONST_ICON_SIZE + textSize + 4) + itempadding * 2; int width = DensityUtil.dip2px(context, CONST_R * 2 + 30) + itemWidth; int height = DensityUtil.dip2px(context, CONST_R * 2 + 30 + textSize) + itemWidth; setWidth(width); setHeight(height); setBackgroundDrawable(new ColorDrawable()); frameLayout = new FrameLayout(context); view_circle = new View(context); view_circle.setBackgroundResource(R.drawable.bg_circle); int Radius = DensityUtil.dip2px(context, CONST_R); int pading = (width - Radius * 2)/2; FrameLayout.LayoutParams view_flp = new FrameLayout.LayoutParams(Radius * 2, Radius * 2); view_flp.leftMargin = view_flp.topMargin = (width - Radius * 2) / 2; frameLayout.addView(view_circle, view_flp); for(int i = 0;i
上一篇:Github项目导入Gitee流程
下一篇:成功解决Keil MDK5中no browse information available in ‘xxx’的问题

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2025年03月21日 00时20分54秒