android环形控件,基于Material Design设计的环形菜单控件

title.png

AnnularMenu is based on Material Design design of the ring menu control. For specific use, please read down.

demo3.gif

b62559eb9d7e93af4943c1061a8fe04b.gif    3c415621f5d8631f1ec035f5cb8bb6c4.gif

Usage

In the module build.gradle

com.dingmouren.annularmenu:annularmenu:1.0.2

Example Usage

1.Layout XML

xmlns:app="http://schemas.android.com/apk/res-auto"

android:orientation="vertical"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:position="left_bottom" //The menu's location

app:radius="120dp" //The radius of the menu

app:toggleDuration="500" //Open / close the menu duration of the animation

>

android:layout_width="60dp"

android:layout_height="60dp"

android:layout_centerHorizontal="true"

app:src="@mipmap/menu" //The first is the button that opens or closes the menu

app:shadowOffsetX="2dp" //The shadow of the offset in the direction of X

app:shadowOffsetY="2dp" //The offset of the shadow in the Y direction

app:shadowRadius="5dp" //Shadow radius

/>

android:layout_width="45dp"

android:layout_height="45dp"

android:layout_centerHorizontal="true"

app:src="@mipmap/item1" //The following are the item menu

app:shadowOffsetX="2dp"

app:shadowOffsetY="2dp"

app:shadowRadius="2dp"

/>

...

2.Java code

menu1.setOnMenuItemClickListener(new AnnularMenu.OnMenuItemClickListener() {

@Override

public void onClick(View view, int position) {

}

});

Attribute

AnnularMenu

Description

position

The menu's location, values are: left_top, left_bottom, right_top, right_bottom, and the default is right_bottom

radius

The radius of the menu, when the number of item items in the menu increases, you need to set the radius to adjust the item spacing

toggleDuration

Open / close the menu duration of the animation, the default is 500 milliseconds

ShadowImageView

Description

shadowOffsetX

The shadow of the offset in the direction of X

shadowOffsetY

The offset of the shadow in the Y direction

shadowRadius

Shadow radius

src

picture

AnnularMenu’Method

AnnularMenu

Description

public boolean isOpen()

Determines whether the menu is open or closed at the moment

public void toggle()

Switch menu

public void setOnMenuItemClickListener(OnMenuItemClickListener onMenuItemClickListener)

Listen for the click of the menu item item

public void setMenuButtonClickable(boolean clickable)

Change the menu button clickable state

Welcome to make suggestions

License

Copyright (C) 2017

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

http://www.apache.org/licenses/LICENSE-2.0

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
    评论
自定义控件是指开发者根据自己的需求和设计来创建一种新的控件,以便在应用程序中使用。环形进度条是一种常见的自定义控件,它以环形的形式展示进度状态。在Qt中,可以通过以下步骤来创建一个环形进度条的自定义控件: 1. 创建一个新的Qt自定义控件类,例如"CustomCircularProgressBar"。这个类应该继承自QWidget或QProgressBar类。QWidget提供了基本的窗口功能,而QProgressBar是一个进度条控件。 2. 在自定义控件类的头文件中,定义私有成员变量来存储进度条的当前值和最大值,并声明一些用于设置和获取这些值的公有方法。 3. 重写自定义控件类的绘图事件函数paintEvent(QPaintEvent *event),在这个函数中绘制环形进度条的外观。可以使用Qt的绘图工具类QPainter来绘制圆形和弧线,并根据当前值和最大值计算出进度的角度。 4. 实现自定义控件类的公有方法,用于设置和获取进度条的当前值和最大值。在这些方法中,更新私有成员变量的值,并调用update()函数来触发控件的重绘。 5. 在应用程序中使用自定义控件类。在Qt的设计工具中,将自定义控件拖放到主窗口或其他需要显示环形进度条的地方,并调用相应的公有方法来设置进度条的值。 通过以上步骤,就可以创建一个自定义的环形进度条控件。开发者可以根据自己的需求,进一步扩展和定制这个控件,例如添加动画效果、改变颜色和样式等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值