sitelink1 https://aroundck.tistory.com/8189 
sitelink2  
sitelink3  

Android View 시스템의 TextView 는 Compose 에서 'Text' 에 매핑된다.

 

#

Text 는 아래와 같은 signature 를 갖고 있다.

fun Text(
    text: String,
    modifier: Modifier = Modifier,
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontStyle: FontStyle? = null,
    fontWeight: FontWeight? = null,
    fontFamily: FontFamily? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    textDecoration: TextDecoration? = null,
    textAlign: TextAlign? = null,
    lineHeight: TextUnit = TextUnit.Unspecified,
    overflow: TextOverflow = TextOverflow.Clip,
    softWrap: Boolean = true,
    maxLines: Int = Int.MAX_VALUE,
    onTextLayout: (TextLayoutResult) -> Unit = {},
    style: TextStyle = LocalTextStyle.current
)

 

#

Text 에 stringRes 를 지정하려면 stringResource 함수를 활용하자.

Text(
	text=stringResource(R.string.app_name),
)

 

#

Text 의 fontSize 지정은 fontSize parameter 를 활용한다. Int.sp 함수가 쓰인 것을 주목하자.

Text(
	text="Hello World",
	fontSize=18.sp,
)

 

#

Text 에 bold 를 추가하려면 fontWeight parameter 를 활용한다.

Text(
	text="Hello World",
	fontWeight = FontWeight.Bold,
)

FontWeight 에는 Thin, Light, Normal, Medium, Bold 와 함께 추가적인 값들 (ex. ExtraBold) 이 있으니 사용시 참고해서 사용하자.

 

#

Text 에 Android View 시스템의 gravity 값을 주려면, textAlign parameter 를 활용하자.

Text(
	text="Hello World",
	textAlign = TextAlign.End,
)

 

#

Text 를 singleLine 처리 하려면 maxLines parameter 를 활용하자.

Text(
	text="Hello World",
	maxLines=1,
)

 

#

Text 에 ellipsize(말줄임. android:ellipsize) 옵션을 주려면 overflow parameter 를 활용하자.

Text(
	text="Hello World",
	overflow=TextOverflow.Ellipsis,
)

TextOverflow 의 constant 는 Clip(잘라내기, 기본값), Ellipsis, Visible(bounds 를 넘어서도 그리는..) 이 있다.

 

#

Text 에 underline (밑줄) 옵션을 주려면 textDecoration parameter 를 활용하자.

Text(
	text="Hello World",
	textDecoration=TextDecoration.Underline,
)

TextDecoration 의 constant 는 None, Underline, LineThrough(취소선) 이 있다.

 

#

Text 에 italic (기울어진) 옵션을 주려면 fontStyle parameter 를 활용하자.

Text(
	text="Hello World",
	fontStyle=FontStyle.Italic,
)

 

#

Text 에 clickListener 를 주기 위해서는 Modifier.clickable 을 활용하자.

Text(
	text="Hello World",
    modifier=Modifier.clickable { /* .. */ },
)

 

번호 제목 글쓴이 날짜 조회 수
128 단말기 고유값 구하는 방법들 황제낙엽 2019.03.03 11739
127 뷰 캡처하여 이미지 파일로 저장하기(화면 캡처)-04 file 황제낙엽 2018.08.12 1711
126 고유 식별자의 모범 사례 (Android Developers) 황제낙엽 2019.03.03 1106
125 Emulator: audio: Failed to create voice `adc' 황제낙엽 2018.08.06 1007
124 뷰 캡처하여 이미지 파일로 저장하기(화면 캡처)-06 file 황제낙엽 2018.08.19 991
123 HTTP 프로토콜을 이용한 Json Post 보내고 받기 file 황제낙엽 2017.08.03 816
122 Error:Execution failed for task ':app:lintVitalRelease'. 황제낙엽 2018.01.29 783
121 파일 입출력(내장 메모리, 외장메모리) 황제낙엽 2018.08.19 720
120 HttpURLConnection 에서 세션 유지하기(쿠키 사용) 황제낙엽 2017.08.03 661
119 [성공샘플] HttpURLConnection 을 이용하여 JSON 데이터 보내기 예제 황제낙엽 2018.11.10 649
118 Image to byte Array (바로 사용가능한 JPEG 파일) 황제낙엽 2018.07.24 612
117 STT 학습 링크 모음 (sample link) 황제낙엽 2018.10.11 552
116 ABI 관리 황제낙엽 2017.03.28 535
115 TTS 를 위한 스마트폰 설정 및 TTS 샘플 file 황제낙엽 2019.02.16 460
114 안드로이드 스튜디오(Android Studio) 최적화 file 황제낙엽 2018.02.07 433
113 android.webkit.CookieManager 를 이용한 웹뷰와의 세션 공유 황제낙엽 2019.04.26 322
112 동적 레이아웃 생성과 자동 줄바꿈 구현 file 황제낙엽 2018.12.26 311
111 Android - Actionbar에 tab을 추가하고 스와이프 동작으로 화면 전환 구현( ViewPager와 FragmentPagerAdapter 사용) file 황제낙엽 2017.09.11 308
110 안드로이드 두지점(위도,경도) 사이의 거리 file 황제낙엽 2017.01.25 257
109 안드로이드 기기 식별 방법 - UUID(Universally unique identifier) 황제낙엽 2019.03.03 234