Android Button – Remove Shadow and Border from Button with Image on it

We can remove the border and shadows from a button by adding the following style code in your activity_main.xml file. Or what ever your XML file is.


Code for button. We are setting an image as the background.


Comparison of buttons. One on the left still has the shadow on it

Difference between border and borderless buttons

More info here

Kotlin – Buttons and TextViews

Set Text for text view

val textBoxVar: TextView = findViewById(
textBoxVar.text = "Hello World!"

Button clicked – do something

val buttonVar: Button = findViewById(
buttonVar.setOnClickListener {
    buttonVar.text = "Button Pushed..."  //Change text on button


Toast notification

val text = "Hello World! This is a toast message!"
val duration = Toast.LENGTH_SHORT
val toast = Toast.makeText(applicationContext, text, duration)

Unity Button can’t access script functions

When you have a button object there is the On Click () area that can execute different actions like a PlayMaker script or a function in a C# script.

Issue with the C# script. You can’t drag and drop the script from the Assets Panel. The script needs to be assigned to an object, then drag and drop that object on the On Click () object. Then select the script and then the function from the drop down there.


Code snippet below is the EnableDisableAudio function that gets executed by the On Click () function above. Note that the script has to be assigned to an object, in this case the button.

    public void EnableDisableAudio()
        if (counter % 2 == 1)
            Debug.Log("ButtonToggled - On");

            Debug.Log("ButtonToggled - Off");

More info