728x90
주요 속성
text : TextView를 통해 보여 줄 문자열
lines : 표시하고자 하는 문자열의 라인 수
textColor : 표시되는 문자열의 색상
textSize : 표시되는 문자열의 크기
textAppearance : 표시되는 문자열의 형식
lines : 표시하고자 하는 문자열의 라인 수
textColor : 표시되는 문자열의 색상
textSize : 표시되는 문자열의 크기
textAppearance : 표시되는 문자열의 형식
주요 프로퍼티
text : TextView를 통해 보여주는 문자열을 관리한다.
주요 메서드
setBackgroundColor : 배경 색상을 지정한다.
setTextColor : 글자 색상을 지정한다.
append : 문자열을 추가한다.
package com.example.textview
import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//뷰의 주소를 받아온다
val text1 = findViewById<TextView>(R.id.text1)
text1.text = "안녕!"
// 'kotlin-android-extensions' 추가하면 사용 가능
// id로 생성된 모든 객체 접근 가능
text2.text = "이게되네?"
text2.setBackgroundColor(Color.BLUE)
// text2.setBackgroundColor(Color.rgb(0,0,0))
text2.append("\n감사합니다")
}
}
추가하면 쉽가 사용 가능
728x90
'안드로이드 > Widget' 카테고리의 다른 글
안드로이드 ToggleButton (0) | 2022.05.30 |
---|---|
안드로이드 ImageView (0) | 2022.05.30 |
안드로이드 TextInputLayout (0) | 2022.05.30 |
안드로이드 EditText (0) | 2022.05.27 |
안드로이드 Button (0) | 2022.05.27 |