MainActivity.kt package com.example.jetpack import android.app.Activity import android.os.Bundle import android.util.TypedValue import android.view.View import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_main.* class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // make the text view clickable materialTextView.apply { isClickable = true isFocusable = true } applySelectableItemBackground(materialTextView) } } // extension function to apply selectable item background fun Activity.applySelectableItemBackground(v:View){ val typedValue = TypedValue() this.theme.resolveAttribute( android.R.attr.selectableItemBackground, typedValue, true ) if (typedValue.resourceId != 0) { v.setBackgroundResour...
Android, .NET C#, Flutter, and Many More Programming tutorials.