Skip to content

Latest commit

 

History

History
193 lines (136 loc) · 6.25 KB

File metadata and controls

193 lines (136 loc) · 6.25 KB

FloatingX

image-20210810161316095

ktlint

FloatingX A flexible and powerful permission-free hover window solution.

中文简介

中午使用文档见这里

👏 Features

  • Single instance holding floating window view
  • Support for various callback listeners
  • Chain calls, senseless insertion
  • Support customizing whether to save history position and restore
  • Support inserting ViewGroup , Fragment , Activity
  • Allow custom hover window indicators, custom hidden display animation
  • Support cross-border rebound, multi-finger touch, small screen adaptation, screen rotation
  • Support custom position direction, with auxiliary positioning display coordinates
  • Perfect kotlin build extensions, and friendly compatibility with Java.
  • Support display location [force fix], for special models (need to open separately)
  • Perfect logging system, open to see different levels of Fx running process, more convenient to find problems
  • ...

👨‍💻‍ Dependencies

Add jitpack repository

build.gradle

Gradle 7.0 and below

allprojects {
		repositories {
			// ...
			maven { url 'https://jitpack.io' }
		}
}

AndroidStudio-Arctic Fox && Gradle7.0+, and have adjusted the dependency method, you may need to add to the following location.

settings.gradle

dependencyResolutionManagement {
repositories {

// ...
maven { url 'https://jitpack.io' }
}
}

Gradle

dependencies {
	  implementation 'com.github.Petterpx:FloatingX:1.1.0'
}

🏄‍♀️ 效果图

全屏,activity,fragment,单view 小屏展示 非正常比例缩放屏幕
效果-展示1 演示-小屏 非正常比例缩放
屏幕旋转 功能演示
演示-旋转 演示-局部功能

Complete log-viewer

Open the log viewer, you will see the whole track of Fx, which is easier to find the problem and track the solution. Also support custom log tag。

App Activity ViewGroup
image-20210808123000851 image-20210808123414921 image-20210808123553402

👨‍🔧‍ Usage

Global hover window management

kt

FloatingX.init {
        setContext(this@CustomApplication)
        setLayout(R.layout.item_floating_new)
  			addBlackClass(
                MainActivity::class.java,
                NewActivity::class.java,
                ImmersedActivity::class.java
         )
  			//only if show is called, it will listen to the app-lifecycle, and then it will be inserted into the activity automatically
        show()
}

Java

AppHelper helper = AppHelper.builder()
        .setContext(application)
        .setLayout(R.layout.item_floating)
        .build();
FloatingX.init(helper);

Local hover window management

Generic creation method

kt

ScopeHelper.builder {
  setLayout(R.layout.item_floating)
}.toControl(activity)

kt && java

ScopeHelper.builder()
            .setLayout(R.layout.item_floating)
            .build()
            .toControl(activity)
            .toControl(fragment)
            .toControl(viewgroup)

extended support for kt

activity create hover window
private val activityFx by activityToFx(activity) {
    setLayout(R.layout.item_floating)
}
fragment to create a hover window
private val fragment by fragmentToFx(fragment) {
    setLayout(R.layout.item_floating)
}
viewGroup creates a hover window
private val viewFx by createFx({
        init(viewGroup)
    }) {
        setLayout(R.layout.item_floating)
        setEnableLog(true, "main_fx")
    }
Quickly create an arbitrary scope hover window
private val customCreateFx by createFx {
    setLayout(R.layout.item_floating)
    build().toControl(activity)
    build().toControl(fragment)
    build().toControl(viewgroup)

👍 Thanks

Base HoverView sourced from FloatingMagnetView of EnFloatingView implementation with some improvements on top of it.

For the measurement of the navigation bar part of the code from, wenlu, and on top of it added more adaptations, has covered 95% of the market models, can be said to be the only tool that can be searched for accurate measurement.