Вот текущая реализация моей функции makeElement():
Код: Выделить всё
private fun makeElement() {
Toast.makeText(this, "makeElement", Toast.LENGTH_SHORT).show()
scrollView = findViewById(R.id.messages_scroll_view)
// Create a new TextView instance
val addEl = TextView(this)
// Generate a unique ID for the TextView
val uniqueId = View.generateViewId()
addEl.id = uniqueId
// Set properties for the TextView
addEl.text = "New TextView"
addEl.textSize = 16f // in sp
addEl.setTextColor(Color.RED)
// Add the TextView to the ScrollView
scrollView.addView(addEl)
}
Я специально ищу рекомендации от опытных разработчиков Android. которые работали с подобными сценариями в Android Studio. Заранее благодарю за помощь!
Подробнее здесь: https://stackoverflow.com/questions/783 ... -in-kotlin
Мобильная версия