달나라 노트

Android Studio - tools.text (개발용 text 표시하기) 본문

Android

Android Studio - tools.text (개발용 text 표시하기)

CosmosProject 2021. 3. 22. 23:39
728x90
반응형

 

 

 

 

 

Android Studio의 activity_main.xml에서 TextView를 이용하면 원하는 글자를 화면에 표시할 수 있습니다.

 

그런데 user로부터 어떤 input이 있어야 그에 대한 결과를 표시하기 위해 TextView를 사용하는데, 이때에는 비어있는 TextView로 코딩을 해놓습니다.

 

그러면 당연히 TextView에는 아무 글자도 표시되지 않을텐데 개발할때만 글자를 표시해두면 좋은 경우가 있습니다.

 

이럴 때 tools:text를 이용합니다.

 

 

activity_main.xml

    <TextView
        android:id="@+id/result"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="36sp"
        tools:text="Test text"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>

TextView에 tools:text라는 부분을 보면 이 부분에 명시된 Test text라는 글자가 아래 이미지처럼 개발 화면에 보일겁니다.

 

하지만 에뮬레이터로 실제 앱을 실행해보면 위 글자는 보이지 않죠.

 

 

 

 

 

 

 

 

728x90
반응형
Comments