0

I have this button, with transparent background, composed of an image and a text:

<Button
    android:id="@+id/settingsBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:drawableTop="@drawable/settings"
    android:text="@string/settings" />

When I click it, I would like to have a feeling of the click, like a blinking of the image. I tried to do this with shapes, but their effect doesn't work on the image. Can you help me?

Zain
  • 37,492
  • 7
  • 60
  • 84
Sommo
  • 37
  • 4
  • you can use selector as a background to reflect click. [see this thread](https://stackoverflow.com/questions/14023886/android-button-selector) – Ved Apr 18 '20 at 20:57

2 Answers2

1

You can try to manipulate the opacity of the Button using Animation when the button is clicked

Button btn = findViewById(R.id.btn_SignIn);

btn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Animation animation = new AlphaAnimation(1, 0.5f); //to change visibility from visible to half-visible
        animation.setDuration(50); // 100 millisecond duration for each animation cycle
        animation.setRepeatMode(Animation.REVERSE); //animation will start from end point once ended.
        btn.startAnimation(animation); //to start animation
    }
});

Result

Zain
  • 37,492
  • 7
  • 60
  • 84
0

Try to use this:

style="?android:attr/borderlessButtonStyle"