### Initialize FloatMenu with Custom Background and Listener Source: https://github.com/crosg/floatmenusample/blob/master/README.md This example demonstrates initializing the `FloatLogoMenu` with a custom logo (from a Bitmap), circular menu background, specific background color, and a drawable background. It also sets a default location and includes an `OnMenuClickListener` to handle item clicks and dismiss events. Note the commented line regarding `SYSTEM_ALERT_WINDOW` permission for older Android versions or specific devices when using `withContext`. ```Java mFloatMenu = new FloatLogoMenu.Builder() .withActivity(mActivity) // .withContext(mActivity.getApplication())//这个在7.0(包括7.0)以上以及大部分7.0以下的国产手机上需要用户授权,需要搭配 .logo(BitmapFactory.decodeResource(getResources(),R.drawable.yw_game_logo)) .drawCicleMenuBg(true) .backMenuColor(0xffe4e3e1) .setBgDrawable(this.getResources().getDrawable(R.drawable.yw_game_float_menu_bg)) //这个背景色需要和logo的背景色一致 .setFloatItems(itemList) .defaultLocation(FloatLogoMenu.RIGHT) .drawRedPointNum(false) .showWithListener(new FloatMenuView.OnMenuClickListener() { @Override public void onItemClick(int position, String title) { Toast.makeText(MainActivity.this, "position " + position + " title:" + title + " is clicked.", Toast.LENGTH_SHORT).show(); } @Override public void dismiss() { } }); ``` -------------------------------- ### Initialize FloatMenu with Resource Logo and Listener Source: https://github.com/crosg/floatmenusample/blob/master/README.md A more concise example of initializing `FloatLogoMenu` using a resource ID for the logo. It sets the background color, enables circular menu background, defines float items, and sets a default location, along with an `OnMenuClickListener` to handle user interactions. ```Java mFloatMenu = new FloatLogoMenu.Builder() .withActivity(mActivity) .logo(R.drawable.yw_image_float_logo) .backMenuColor(0xffe4e3e1) .drawCicleMenuBg(true) .setFloatItems(itemList) .defaultLocation(FloatLogoMenu.RIGHT) .drawRedPointNum(false) .showWithListener(new FloatMenuView.OnMenuClickListener() { @Override public void onItemClick(int position, String title) { Toast.makeText(MainActivity.this, "position " + position + " title:" + title + " is clicked.", Toast.LENGTH_SHORT).show(); } @Override public void dismiss() { } }); ``` -------------------------------- ### Add FloatMenu Dependency (Version 1.0.0) Source: https://github.com/crosg/floatmenusample/blob/master/README.md The initial version of the `FloatMenu` library, which supported both desktop and in-app floating windows (this functionality was later removed or changed in subsequent versions). ```Gradle compile 'com.yw.game.floatmenu:FloatMenu:1.0.0' ``` -------------------------------- ### Add FloatMenu Dependency (Current 2.0.1) Source: https://github.com/crosg/floatmenusample/blob/master/README.md Add the `FloatMenu` library as a compile dependency in your Android project's `build.gradle` file to include the latest stable version (2.0.1). This version allows optional desktop support (with `SYSTEM_ALERT_WINDOW` permission) and does not require `windows.addContentView`. ```Gradle compile 'com.yw.game.floatmenu:FloatMenu:2.0.1' ``` -------------------------------- ### Add FloatMenu Dependency (Version 2.0.0) Source: https://github.com/crosg/floatmenusample/blob/master/README.md The refactored version 2.0.0 of `FloatMenu`, primarily focusing on in-app floating windows. This version used the `windows.addContentView` interface and required a specific meta-data tag (`unityplayer.ForwardNativeEventsToDalvik`) to be enabled for Unity3D game engines. ```Gradle compile 'com.yw.game.floatmenu:FloatMenu:2.0.0' //2.0.0版使用windows.addContentView接口,在unity3D游戏引擎需要开启该选项 ``` -------------------------------- ### Customize Float Dialog by Implementing Interface Source: https://github.com/crosg/floatmenusample/blob/master/README.md This snippet shows how to customize the float dialog by implementing the `BaseFloatDailog.FloatDialogImp` interface, providing a `GetViewCallback` for custom view handling. ```Java BaseFloatDailog mBaseFloatDailog = new BaseFloatDailog.FloatDialogImp(this, new BaseFloatDailog.GetViewCallback() {}); ``` -------------------------------- ### Customize Float Dialog by Extending BaseFloatDailog Source: https://github.com/crosg/floatmenusample/blob/master/README.md This snippet illustrates how to customize the float dialog by extending the `BaseFloatDailog` class, allowing for custom implementations and overriding its behavior. ```Java public class MyFloatDialog extends BaseFloatDailog { .... } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.