TextButton

Additional

Language
Java
Version
1.0.4 (Jun 11, 2018)
Created
May 30, 2018
Updated
Jul 2, 2018
Owner
段弘 (duanhong169)
Contributor
段弘 (duanhong169)
1
Activity
Badge
Generate
Download
Source code
APK file

Advertisement

Text Button

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

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.