منو متحرک دایره ای
30 شهریور 1399 1399-07-07 4:52منو متحرک دایره ای
یه کتابخونه عالی برای نمایش متفاوت منوهای برنامه. با این کتابخونه خیلی راحت میتونی منوهای متحرک و دایره ای رو به برنامه ت اضافه کنی.
اول از همه این کد رو به app/build.gradle اضافه کن
implementation 'com.github.imangazalievm:circlemenu:3.0.0'
خب، بعد از از اینکه پروژه رو sync کردی، کتابخونه به برنامه اضافه میشه. حالا باید ازش استفاده کنی
برای اینکه از منو توی فایل layout استفاده کنی باید این کد رو به xml لایه مورد نظرت اضافه کنی
<com.imangazaliev.circlemenu.CircleMenu android:id="@+id/circleMenu" android:layout_width="wrap_content" android:layout_height="wrap_content" app:buttonColors="@array/colors" app:buttonIcons="@array/icons" />
حالا دیگه تقریبا کار تمومه، بقیه خصوصیات منو رو باهم بررسی می کنیم.
متد هندل کردن کلیک آیتم های مختلف منو :
val circleMenu = findViewById<CircleMenu>(R.id.circleMenu) circleMenu.setOnItemClickListener { menuButton -> }
از متد زیر که یک boolean هستش، میتونی برای باز و بسته کردن منو ازش استفاده کنی
circleMenu.open(true)
متدهای هندل کردن باز و بسته شدن آیتم های منو
circleMenu.setOnItemClickListener { buttonIndex -> } circleMenu.onMenuOpenAnimationStart { } circleMenu.onMenuOpenAnimationEnd { } circleMenu.onMenuCloseAnimationStart { } circleMenu.onMenuCloseAnimationEnd { } circleMenu.onButtonClickAnimationStart { buttonIndex -> } circleMenu.onButtonClickAnimationEnd { buttonIndex -> }
و در نهایت خصوصیات زیر هم برای شخصی سازی منو هاستش که توی تکه کد xml میتونی ازش استفاده کنی
buttonIcons (required) - icons of menu buttons buttonColors (required) - background colors of menu buttons iconsColor (optional) - color of buttons icons startAngle (optional) - start circle angle maxAngle (optional) - maximum degree of the menu arc distance (optional) - the distance between center menu and buttons (radius) centerButtonColor (optional) - background color of center menu button centerButtonIconColor (optional) - icon background color of center menu button menuIcon (optional) - center button icon type: hamburger or plus openOnStart (optional) - open the menu when the screen starts showSelectAnimation (optional) - show select animation when clicking on on a button or just close the menu
نمونه استفاده شده در BottomAppBar :
نمونه استفاده شده در FAB :