I am using Android Java in Android Studio with this project. I am trying to make a pulsating shadow for my button. I want it so whenever the user clicks the wrong button, I bring attention to the button they should click by making pulsating a shadow. I have looked through many forums and posts with no success. If there is a different way to do this, please let me know. Thanks!
EDIT: Here's some code I was working on:
newTimerTask = new TimerTask() {
@Override
public void run() {
ObjectAnimator colorFade = ObjectAnimator.ofObject(start_stop_btn, "background", new ArgbEvaluator(), R.drawable.button_shadow, 0xff000000);
colorFade.setDuration(7000);
colorFade.start();
start_stop_btn.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.button_shadow);
}
};
Timer newTimer = new Timer();
newTimer.schedule(newTimerTask, 0, 100);
button_shadow.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item android:right="5dp" android:top="5dp">
<shape>
<corners android:radius="3dp" />
<solid android:color="#D6D6D6" />
</shape>
</item>
<item android:bottom="2dp" android:left="2dp">
<shape>
<gradient android:angle="270"
android:endColor="#E6E600" android:startColor="#FFFF00" />
<stroke android:width="1dp" android:color="#BABABA" />
<corners android:radius="4dp" />
<padding android:bottom="10dp" android:left="10dp"
android:right="10dp" android:top="10dp" />
</shape>
</item>
</layer-list>
</item>
Thanks in advance!
There is no such attribute in Android
, to show a shadow.
You can do a work around like this :
Take LinearLayout
or Framelayout
with grey color, under your Button
, with margin
at bottom and right equal to 1 or 2 dp
.
Make it visible when wrong Button
is clicked.
Thats the best I can suggest for your requirement.
My suggestion is to get a good animation to catch user attention though.