This is my code for ripple effect:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="@color/button_layout_ropple"
tools:targetApi="lollipop">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="@color/button_layout_ropple" />
</shape>
</item>
</ripple>
and Textview xml code is:
<TextView
android:layout_width="match_parent"
android:id="@+id/output"
android:textSize="20sp"
android:foreground="@drawable/ripple_effect"
android:background="#f4de97"
android:text="Result"
android:layout_height="65dp"
android:clickable="true" />
Ripple effect created when the Textview touched but I want to create this by pressing a button. Is it possible? If possible how can I do it?
Here is the code of that button:
<Button
android:id="@+id/buttonClear"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="clear"
android:background="#ECEFF1"
android:textColor="#000000"
android:textSize="20dp" />
button handler code is:
buttonClear.setOnClickListener(
new Button.OnClickListener() {
public void onClick(View v) {
input.setText(null);
output.setText("output");
}
}
);
I want ripple effect will appear on Textview by pressing this button.