android自定义弧形菜单,AndroidArcMenu 首创 Android 的户型菜单,相比 Path 的弧形菜单,本菜单添加了文字部分用以说明菜单 @codeKK Android开源站...

android arc menu with a float button ,this view is made for the purpose of fitting big screen.

Demo

3497e6842e763e9f3c63d8549a0cd9a3.png

df27b990e411c7df2cb4b31294c0f0ba.gif

Usage

in order to use this view, there are 3 steps:

set the parent view of the menu

menu.setParentBlurView(rlParent);

create a item click listener to handle the user click

GFloatingMenu.OnItemClickListener mListener;

add menu item

menu.AddMenuItem((bitmap)icon, "some menu item", mListener);

Library licenses

Copyright 2016 PAVKOO

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用 Android 中的 PopupWindow 和自定义 View 实现弧形弹出按钮菜单。 1. 首先,您需要在布局文件中添加一个按钮,该按钮将用作触发器来显示/隐藏菜单。例如: ```xml <Button android:id="@+id/btn_menu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Menu" /> ``` 2. 创建一个自定义 View,用于显示您的菜单项。您可以使用 Canvas 和 Path 来绘制弧形形状。例如: ```java public class ArcMenuView extends View { private final Paint mPaint; private final Path mPath; public ArcMenuView(Context context) { super(context); mPaint = new Paint(); mPaint.setColor(Color.WHITE); mPaint.setStyle(Paint.Style.FILL); mPath = new Path(); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // 绘制弧形 mPath.reset(); mPath.moveTo(0, getHeight()); mPath.arcTo(new RectF(0, 0, getWidth(), getHeight()), 180, -180); mPath.close(); canvas.drawPath(mPath, mPaint); // 绘制菜单项 // ... } } ``` 3. 在您的 Activity 或 Fragment 中,初始化 PopupWindow 并将其设置为自定义 View。例如: ```java final PopupWindow popupWindow = new PopupWindow(context); final View menuView = LayoutInflater.from(context).inflate(R.layout.popup_menu, null); popupWindow.setContentView(menuView); popupWindow.setWidth(WindowManager.LayoutParams.MATCH_PARENT); popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); final ArcMenuView arcMenuView = menuView.findViewById(R.id.arc_menu_view); // 设置菜单项 // ... final Button btnMenu = findViewById(R.id.btn_menu); btnMenu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (popupWindow.isShowing()) { popupWindow.dismiss(); } else { popupWindow.showAsDropDown(btnMenu); } } }); ``` 您可以在自定义 View 中添加菜单项,并在 onDraw() 方法中绘制它们。在 onClick() 方法中,使用 showAsDropDown() 和 dismiss() 方法来显示/隐藏 PopupWindow。 您可以根据自己的需求自定义菜单项的样式和行为。希望这能帮助到您!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值