Layout File.xml
<ToggleButton
android:id="@+id/toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:background="@drawable/check"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
In main activity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ToggleButton mic = (ToggleButton)findViewById(R.id.toggle);
mic.setTextOff(null);
mic.setTextOn(null);
mic.setText(null);
check.xml which is used by layout.xml
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/mic_on"
android:state_checked="true">
</item>
<!-- When not selected, use white-->
<item android:drawable="@drawable/mic_off"
android:state_checked="false">
</item>
These lines are those what you are looking for
mic.setTextOff(null);
mic.setTextOn(null);
mic.setText(null);