Skip to content

⏹️ An easy to use `TextButton` when you need a TextView-like button, with handy touch feedback effects.

License

Notifications You must be signed in to change notification settings

duanhong169/TextButton

Repository files navigation

Text Button gitHub release platform Android Arsenal license Build status

An easy to use TextButton when you need a TextView-like button, with handy touch feedback effects.

screen-record

Gradle

dependencies {
    implementation 'com.github.duanhong169:text-button:${latestVersion}'
    ...
}

Replace ${latestVersion} with the latest version code. See releases.

Usage

Use the built-in effects

Config TextButton in xml:

<top.defaults.view.TextButton
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="animateTextColor"
    android:padding="4dp"
    android:textSize="16sp"
    app:defaultTextColor="@android:color/holo_blue_dark"
    app:pressedTextColor="@android:color/holo_orange_dark"
    app:disabledTextColor="@android:color/darker_gray"
    app:underline="true"
    app:effectDuration="200"
    app:textEffect="animateColor"
    app:backgroundEffect="ripple"/>

There are 4 text effects: default, animateColor, animateSize and animateColorAndSize and 3 background effects: colorState, ripple, animateColor for now.

See top_defaults_view_attrs.xml for all supported attributes.

Implement your own effect

button5.setEffect(new TextButtonEffect() {
    private TextButton textButton;

    @Override
    public void init(TextButton textButton) {
        this.textButton = textButton;
    }

    @Override
    public void actionDown() {
        textButton.setAlpha(0.5f);
    }

    @Override
    public void actionUp() {
        textButton.setAlpha(1);
    }
});

For more details, see the sample app.

License

See the LICENSE file.

About

⏹️ An easy to use `TextButton` when you need a TextView-like button, with handy touch feedback effects.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages