App노자
[Android] TextView 본문
1. TextView란?
TextView는 사용자 인터페이스에 텍스트를 표시하는 데 사용되는 Widget이다 TextView를 사용하면
앱 내에서 텍스트를 표시하거나 레이아웃에 텍스트를 추가할 수 있다
https://developer.android.com/reference/android/widget/TextView
2. XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/edit_text"
android:layout_width="150dp"
android:layout_height="50dp"
app:layout_constraintBottom_toTopOf="@+id/text_view"
android:layout_marginBottom="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
XML파일에 <TextView />, 를 작성한 후 그 안에 제약이나 id를 적는다
2. 자주 사용되는 속성들
android:text="Hello World!"
android:textColor="@color/white"
android:textSize="10dp"
android:textStyle="normal"
android:autoLink="web"
android:maxLines="2"
android:ellipsize="end"
android:singleLine="true"
android:lines ="3"
android:inputType=""
text: 출력할 문자열을 지정한다 문자열을 바로 대입해도 되고 따로 문자열 리소스(@string)를 작성해서 지정을 해도 된다
https://developer.android.com/reference/android/widget/TextView
- build.gradle 빌드 설정 파일
gradle은 안드로이드의 빌드 도구이다 앱을 빌드하는데 필요한 내용을 gradle에 등록한다
프로젝트 수준의 build.gradle과 모듈 수준의 build.gradle 2개로 나뉘는데 빌드 설정은 모듈 수준의 gradle에 작성한다
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
플러그인을 선언한 내용
android {
compileSdk 32
defaultConfig {
applicationId "com.example.study_kotlin"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
}
compileSdk 32: 컴파일하거나 빌드할 떄 적용할 버전을 설정한다
'Android > AndroidStudio' 카테고리의 다른 글
[Android] LinearLayout (0) | 2022.06.16 |
---|---|
[Android] EditText (0) | 2022.06.15 |
[Android] Button, CheckBox, RadioButton (0) | 2022.06.11 |
[Android] View 클래스 (0) | 2022.06.06 |
[Android] Activity (0) | 2022.05.31 |