App노자
[Android] EditText 본문
TextView란?
문자열을 화면에 출력하는 뷰다
View 클래스 바로 다음에 위치하며 EditText, Button, CheckBox등의 다양한 위젯이 하위에 존재한다
EditText란?
사용자가 글을 입력할 수 있는 뷰다
어떤 값을 입력받기 위해 사용되어 활용도가 높고 View, TextView를 상속 받는다
1. 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)를 작성해서 지정을 해도 된다
'Android > AndroidStudio' 카테고리의 다른 글
[Android] RelativeLayout (0) | 2022.06.20 |
---|---|
[Android] LinearLayout (0) | 2022.06.16 |
[Android] Button, CheckBox, RadioButton (0) | 2022.06.11 |
[Android] TextView (0) | 2022.06.08 |
[Android] View 클래스 (0) | 2022.06.06 |