Skip to content
FloatingView moved by finger supporting OverlaySystem, OverlayActivity, OverlayViewGroup modes
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
floatingview
gradle/wrapper
media
.gitignore
README.md
READMEcn.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

FloatingView

Platform API License

中文看这里

Features

  • Support three modes: OverlaySystemOverlayActivity and OverlayViewGroup
  • OverlaySystem: Display FloatingView above other apps
  • OverlayActivity: Display FloatingView above certain Activity
  • OverlayViewGroup: Display FloatingView above certain ViewGroup
  • Move FloatingView with finger
  • Define 9 initial position for FloatingView
  • Define initial paddings for FloatingView

Usage

Step 1

Add it in your build.gradle at the end of repositories:

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

Add the dependency in the form:

dependencies {
    compile 'com.github.hzw1199:FloatingView:1.0.0'
}

Step 2

Configure and display

  • OverlaySystem mode

onCreate:

FloatingViewConfig config = new FloatingViewConfig.Builder()
        .setPaddingLeft(paddingLeft)
        .setPaddingTop(paddingTop)
        .setPaddingRight(paddingRight)
        .setPaddingBottom(paddingBottom)
        .setGravity(gravity)
        .build();
floatingView = new FloatingView(OverlaySystemActivity.this, R.layout.view_floating, config);
floatingView.showOverlaySystem();

onDestroy:

if (floatingView != null) {
    floatingView.hide();
}
  • OverlayActivity mode

onAttachedToWindow:

FloatingViewConfig config = new FloatingViewConfig.Builder()
        .setPaddingLeft(paddingLeft)
        .setPaddingTop(paddingTop)
        .setPaddingRight(paddingRight)
        .setPaddingBottom(paddingBottom)
        .setGravity(gravity)
        .build();
floatingView = new FloatingView(OverlaySystemActivity.this, R.layout.view_floating, config);
floatingView.showOverlayActivity();

onDetachedFromWindow:

if (floatingView != null) {
    floatingView.hide();
}
  • OverlayViewGroup mode

onCreate:

lyViewGroup.post(new Runnable() {
    @Override
    public void run() {
		FloatingViewConfig config = new FloatingViewConfig.Builder()
		        .setPaddingLeft(paddingLeft)
		        .setPaddingTop(paddingTop)
		        .setPaddingRight(paddingRight)
		        .setPaddingBottom(paddingBottom)
		        .setGravity(gravity)
		        .setDisplayWidth(lyViewGroup.getWidth())
		        .setDisplayHeight(lyViewGroup.getHeight())
		        .build();
		floatingView = new FloatingView(OverlaySystemActivity.this, R.layout.view_floating, config);
		floatingView.showOverlayViewGroup(lyViewGroup);
    }
});

onDestroy:

if (floatingView != null) {
    floatingView.hide();
}

lyViewGroup is the ViewGroup to display FloatingView above

Step 3

Click event

floatingView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        
    }
});

Proguard

No need to add more proguard rules, consumerProguardFiles has already handled library proguard rules.

Tip

  • Please check the demo before use.
  • If this project helps you, please star me.

About Me

License

The MIT License (MIT)

Copyright (c) 2019 FloatingView

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
You can’t perform that action at this time.