Please see the SteadyScreen project for more details.
- SteadyScreen service app: The engine behind the scenes.
- SteadyViews library: Ready-to-use "Steady…" implementations of most common Android layouts (like e.g. LinearLayout or ConstraintLayout).
- SteadyView library (this): Core classes and methods. To be used for custom View or ViewGroup implementations.
- SteadyService library: Details of the service implementation.
This library enables you to implement the functionality in your own custom View or ViewGroup. If you need ready-to-use "Steady…" implementations of most common Android layouts (like e.g. LinearLayout or ConstraintLayout), you can use the SteadyViews library instead.
- Add the following line to your
build.gradle
file (find more info at https://jitpack.io/#Sublimis/SteadyView):
implementation 'com.github.Sublimis:SteadyView:1.3.1'
- Let your custom
android.view.View
orandroid.view.ViewGroup
implement thelib.sublimis.steadyview.ISteadyView
helper interface. Call theISteadyView.super.initSteadyView()
from every constructor of your custom view.
public class MyView extends View implements ISteadyView
{
public MyView(final Context context)
{
super(context);
ISteadyView.super.initSteadyView();
}
...
}
- Override the
android.view.View.performAccessibilityAction(int, Bundle)
method, from which you should call theISteadyView.super.performSteadyViewAction(int, Bundle)
, like so:
@Override
public boolean performAccessibilityAction(final int action, @Nullable final Bundle arguments)
{
final boolean status = ISteadyView.super.performSteadyViewAction(action, arguments);
return super.performAccessibilityAction(action, arguments) || status;
}
-
Install and enable the SteadyScreen accessibility service from the Play Store.
-
Enjoy!
Call the ISteadyView.setSteadyViewEnabled(final boolean enabled)
method on your ISteadyView to disable or (re)enable the functionality.
Disable:
myView.setSteadyViewEnabled(false);
Enable:
myView.setSteadyViewEnabled(true);
Note, this does not disable/enable the service, it just tells the View to ignore all service inputs.
Call the boolean ISteadyView.isSteadyViewEnabled()
on your ISteadyView to check the enabled state.
Below is the complete implementation of the functionality in a custom view that overrides the plain android.view.View
.
If you need ready-to-use "Steady…" implementations of the most common Android layouts (like e.g. LinearLayout or ConstraintLayout), you can use the SteadyViews library instead.
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
import lib.sublimis.steadyview.ISteadyView;
public class SteadyView extends View implements ISteadyView
{
public SteadyView(final Context context)
{
super(context);
ISteadyView.super.initSteadyView();
}
public SteadyView(final Context context, @Nullable final AttributeSet attrs)
{
super(context, attrs);
ISteadyView.super.initSteadyView();
}
public SteadyView(final Context context, @Nullable final AttributeSet attrs, final int defStyleAttr)
{
super(context, attrs, defStyleAttr);
ISteadyView.super.initSteadyView();
}
public SteadyView(final Context context, @Nullable final AttributeSet attrs, final int defStyleAttr, final int defStyleRes)
{
super(context, attrs, defStyleAttr, defStyleRes);
ISteadyView.super.initSteadyView();
}
@Override
public boolean performAccessibilityAction(final int action, @Nullable final Bundle arguments)
{
final boolean status = ISteadyView.super.performSteadyViewAction(action, arguments);
return super.performAccessibilityAction(action, arguments) || status;
}
}