0

I am trying a login form using Anko vertical layout. Trying to change the background and text color of the button like below. But it is not working.

class LoginActivity : AppCompatActivity() {

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    LoginActivityUI().setContentView(this)   } }

class LoginActivityUI : AnkoComponent<LoginActivity> {

  override fun createView(ui: AnkoContext<LoginActivity>) = with(ui) {
    verticalLayout {
      padding = dip(22)
      var userName = editText()
      userName.hint = "Enter UserName"

      var passWord = editText()
      passWord.hint = "Enter Password"

      var button = button {
        backgroundColor = R.color.colorPrimary
        text = "SignIn"
        textColor = android.R.color.white
      }

    }   
}

}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Raja Jawahar
  • 6,742
  • 9
  • 45
  • 56

1 Answers1

0

At last I found the answer for the question:

backgroundColor = ContextCompat.getColor(context,R.color.colorPrimary)
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Raja Jawahar
  • 6,742
  • 9
  • 45
  • 56