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

Android View 시스템의 ImageButton 는 Compose 에서 'IconButton' 에 매칭된다.

 

#

IconButton 의 function signature 는 아래와 같다.

@Composable
fun IconButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    content: @Composable () -> Unit
)

 

#

Button 과의 차이점은 IconButton 은 내부에 보통 Icon 을 포함하고, Button 은 내부에 보통 Text 를 포함한다.

일반적인 IconButton 용례는 아래와 같다.

IconButton(onClick = { /* .. */ }){
    Icon(
	imageVector = Icons.Filled.ExpandMore,
        tint = MaterialTheme.color.secondary,
        contentDescription = null,
    )
}

 

#

여기서 Icon 에 대해서도 조금 알아보자.

Icon 의 function description 은 아래와 같다.

fun Icon(
    painter: Painter, // bitmap: ImageBitmap, imageVector: ImageVector 가 올 수 있음 
    contentDescription: String?,
    modifier: Modifier = Modifier,
    tint: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current)
)

 

위 예시에서는 Icons.Filled.ExpandMore 를 사용했는데, 이는 Material Design 에서 제공하는 vector 로 gradle 에 아래 dependency 를 추가해야 사용 가능하다.

implementation "androidx.compose.material:material-icons-extended:$compose_version"

 

제공되는 icon 들은 아래 링크에서 확인 할 수 있다.

Material Symbols and Icons

 

번호 제목 글쓴이 날짜 조회 수
128 PC를 위한 최고의 안드로이드 에뮬레이터 황제낙엽 2023.01.18 2
127 [Jetpack Compose UI / 상추님] GDG Jetpack compose 코드랩 수료 후기 (feat. 굿즈) 황제낙엽 2022.12.24 1
126 [Jetpack Compose UI / kyj1991719] compose - Compose 이해 황제낙엽 2022.12.24 3
125 [Jetpack Compose UI / 꾸준] Compose 가 뭔데...? 황제낙엽 2022.12.24 0
124 [Jetpack Compose UI / IIVIKI] Compose 학습과 분석 황제낙엽 2022.12.24 1
123 [Jetpack Compose UI] 스터디 시작하기 황제낙엽 2022.12.24 0
122 [개발하는 정대리] 취준생을 위한 안드로이드 앱만들기 - 바텀네비게이션 뷰, 네비게이션 AAC file 황제낙엽 2022.12.22 1
121 [개발하는 정대리] 취준생을 위한 안드로이드 앱만들기 - 뷰바인딩 file 황제낙엽 2022.12.22 0
120 [개발하는 정대리] 취준생을 위한 안드로이드 앱만들기 - 라이브데이터 뷰모델 file 황제낙엽 2022.12.21 5
» [대왕놀] ImageButton in Compose (IconButton) 황제낙엽 2022.12.20 2
118 [대왕놀] compose instrumentation test tutorial 황제낙엽 2022.12.20 1
117 [대왕놀] Switch in Compose 황제낙엽 2022.12.20 0
116 [대왕놀] EditText in Compose (TextField) 황제낙엽 2022.12.20 0
115 [대왕놀] margin in Compose 황제낙엽 2022.12.20 0
114 [대왕놀] modifier in compose 황제낙엽 2022.12.20 1
113 [대왕놀] Button in Compose file 황제낙엽 2022.12.20 0
112 [대왕놀] TextView in Compose (Text) 황제낙엽 2022.12.20 0
111 [대왕놀] ImageView in Compose (Image) 황제낙엽 2022.12.20 1
110 [대왕놀] LinearLayout in Compose (Row, Column) 황제낙엽 2022.12.20 0
109 [대왕놀] Introduction to Jetpack compose 황제낙엽 2022.12.20 1