๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ

(377)
[Android][Kotlin] ๋ฌธ๊ตฌ ๋ถ€๋ถ„ ์ƒ‰ ๋ณ€๊ฒฝ SpannedString ์ข…์† ํ•ญ๋ชฉ ์„ ์–ธ build.gradle ์•ˆ implementation "androidx.core:core-ktx:$core_version" Utility fun String.targetColorSpan( emphasisString: String, @ColorInt colorRes: Int ): SpannedString { if(!this.contains(emphasisString)) return SpannedString(this) val splitStrings = this.split(emphasisString.toRegex()) return buildSpannedString { append(splitStrings[0]) color(colorRes) { append(emphasisString) } appe..
[Kotlin]Bubble Sort ์ธ์ ‘ํ•œ ๋‘ ๊ฐœ์˜ ์š”์†Œ๋“ค์„ ๋น„๊ตํ•˜๋ฉฐ ์ •๋ ฌํ•œ๋‹ค. ๊ธฐ๋ณธ swap fun ArrayList.swap(firstIndex: Int, secondIndex: Int) { val temp = this[firstIndex] this[firstIndex] = this[secondIndex] this[secondIndex] = temp } Bubble sort fun ArrayList.bubbleSort(showLog: Boolean = true) : ArrayList { if (this.size < 2) { println("๋ฐฐ์—ด์˜ ํฌ๊ธฐ๊ฐ€ 2 ๋ฏธ๋งŒ. ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜.") return this } for (end in lastIndex downTo 1) { var swapped = false for(current in 0 un..
[Android][View] ๋ทฐ๊ฐ€ layout์„ ์ง„ํ–‰ํ•˜๋Š” ์ค‘์— requestLayout()์„ ํ˜ธ์ถœํ•˜๋ฉด ์•ˆ๋œ๋‹ค. https://www.youtube.com/watch?v=HbAeTGoKG6k ๋ฌด๋ ค 13๋…„ ์ „์˜ ์˜์ƒ. ๊ทธ๋Ÿฌ๋‚˜ ์ง€๊ธˆ๋„ ์ค‘์š”ํ•œ ๊ธฐ๋ณธ ์ง€์‹์œผ๋กœ ์•Œ์•„๋‘˜ ํ•„์š”๊ฐ€ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค. ์š”์•ฝ ์ง„ํ–‰ํ•œ ๋ฐ๋ชจ (์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์•ˆ๋ฉ๋‹ˆ๋‹ค. ๋‚˜์œ ์˜ˆ์‹œ) 1. LinearLayout ์„ ์ƒ์†ํ•œ Custom Layout์ด layout ๊ณผ์ •์„ ์ง„ํ–‰ํ•˜๋Š” ์ค‘์—, ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ onLayout()์„ ํ˜ธ์ถœํ•ด ์‹คํ–‰ํ•˜๋Š” ์ค‘์— 2. ์ž๋…€ ๋ทฐ๋ฅผ add ํ•˜๊ฑฐ๋‚˜(addView()) remove ํ•˜๋ฉด(removeView()) 3. ๊ฒฐ๋ก  : ์ด์Šˆ๊ฐ€ ์ƒ๊ธด๋‹ค. > ์ผ์ข…์˜ ์žฌ๊ท€๋ฌธ์ œ๊ฐ€ ์ƒ๊ธด๋‹ค. layout ์ค‘ : ์ผ๋ถ€ ํ•˜์œ„ ์ง‘ํ•ฉ(์ž๋…€ ๋ทฐ๋“ค)์ด๋‚˜ ์ „์ฒด ๋ทฐ ๊ณ„์ธต ๊ตฌ์กฐ๋ฅผ ์žฌ๋ฐฐ์น˜ํ•˜๋Š” ์ค‘์ธ๋ฐ ์ด ํƒ€์ด๋ฐ์— addView(), removeView() ํ˜ธ์ถœ : ๋ ˆ์ด์•„์›ƒ ์ „์ฒด์— ์˜ํ–ฅ์„..
[Android] ํ™”๋ฉด ์ „ํ™˜ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์‹œ์ž‘ ๋””์ž์ด๋„ˆ๊ฐ€ ์•ฑ ์ „๋ฐ˜์ ์œผ๋กœ ํ™”๋ฉด ์ „ํ™˜ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ถ”๊ฐ€๋ฅผ ์š”์ฒญํ–ˆ๋‹ค. ์š”๊ตฌ ์‚ฌํ•ญ ์•ฑ์˜ ํ™”๋ฉด ์ข…๋ฅ˜๋Š” ํฌ๊ฒŒ ๋‘˜๋กœ ๋‚˜๋‰œ๋‹ค. ์ƒ๋‹จ ํˆด๋ฐ” ๋ฒ„ํŠผ ์ข…๋ฃŒ ๋ชจ์–‘์ด ํ™”์‚ดํ‘œ(←)์ธ ๊ฒƒ๊ณผ ์—‘์Šค(X)์ธ ๊ฒƒ์œผ๋กœ ๋‚˜๋‰œ๋‹ค. 1. ←ํ™”๋ฉด์— ์ง„์ž…ํ•  ๋•Œ ๊ฐ€๋ ค์ง€๋Š” ํ™”๋ฉด์€ fade out ์ง„์ž…ํ•˜๋Š” ํ™”๋ฉด์€ ์˜ค๋ฅธ์ชฝ์—์„œ ์™ผ์ชฝ์œผ๋กœ ์Šฌ๋ผ์ด๋“œํ•˜๋ฉฐ ์ง„์ž… 2. ←ํ™”๋ฉด์ด ์‚ฌ๋ผ์ง€๊ณ  ์ด์ „ ํ™”๋ฉด์œผ๋กœ ๋Œ์•„๊ฐˆ ๋•Œ ๋“ฑ์žฅํ•˜๋Š” ์ด์ „ ํ™”๋ฉด์€ fade in ์‚ฌ๋ผ์ง€๋Š” ํ™”๋ฉด์€ ์™ผ์ชฝ์œผ๋กœ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์Šฌ๋ผ์ด๋“œํ•˜๋ฉฐ ์‚ฌ๋ผ์ง 3. X ํ™”๋ฉด์— ์ง„์ž…ํ•  ๋•Œ ๊ฐ€๋ ค์ง€๋Š” ํ™”๋ฉด์€ fade out ์ง„์ž…ํ•˜๋Š” ํ™”๋ฉด์€ ์•„๋ž˜์—์„œ ์œ„๋กœ ์Šฌ๋ผ์ด๋“œํ•˜๋ฉฐ ์ง„์ž… 4. X ํ™”๋ฉด์ด ์‚ฌ๋ผ์ง€๋กœ ์ด์ „ ํ™”๋ฉด์œผ๋กœ ๋Œ์•„๊ฐˆ ๋•Œ ๋“ฑ์žฅํ•˜๋Š” ์ด์ „ ํ™”๋ฉด์€ fade in ์ง„์ž…ํ•˜๋Š” ํ™”๋ฉด์€ ์œ„์—์„œ ์•„๋ž˜๋กœ ์Šฌ๋ผ์ด๋“œํ•˜๋ฉฐ ์‚ฌ๋ผ์ง ๊ณผ์ • 1) ๋””์ž์ด๋„ˆ๊ฐ€ ์›..
[Android][Dialog] cancel / dismiss ์ด์ „์— dialog cancel() ํ˜ธ์ถœ ์‹œ dismiss()๋„ ํ˜ธ์ถœ ๋œ๋‹ค๋Š” ๊ธ€์„ ์ผ๋˜ ๊ฑฐ ๊ฐ™์€๋ฐ. ์ž‘์—…ํ•˜๋‹ค dialog์˜ cancel๊ณผ dismiss์˜ ์ฐจ์ด๊ฐ€ ๋˜ ํ—ท๊ฐˆ๋ ค์„œ, ์ด๋ฒˆ์— ํ™•์‹คํžˆ ๊ทธ ์ฐจ์ด๋ฅผ ์ธ์ง€ํ•˜๊ณ  ๊ฐ€๋ ค๊ณ  ๊ธ€์„ ๋‚จ๊ธด๋‹ค. ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ๋ณด๊ณ  ์ดํ•ดํ–ˆ๋‹ค. https://developer.android.com/develop/ui/views/components/dialogs#DismissingADialog Dialogs | Android Developers Dialogs Stay organized with collections Save and categorize content based on your preferences. A dialog is a small window that prompts the u..
[Android][Android 13][API Level 33] ๋Ÿฐํƒ€์ž„ ์•Œ๋ฆผ ๊ถŒํ•œ, ๊ทธ๋ฆฌ๊ณ  ๊ธฐํš ๋ณ€๊ฒฝ ์‹œ์ž‘. ์ด์Šˆ ๋ฐœ๊ฒฌ Android 13 ๋‹จ๋ง์—์„œ ํ‘ธ์‹œ๋ฅผ ๋ฐ›๊ณ  ์‹œ์Šคํ…œ ์•Œ๋ฆผ์„ ๋„์šฐ์ง€ ๋ชปํ•˜๋Š” ์ด์Šˆ๊ฐ€ ์žˆ์Œ์„ ์•Œ๊ฒŒ ๋๋‹ค. ์›์ธ ํŒŒ์•… Android 13๋ถ€ํ„ฐ ์ƒˆ๋กœ ์„ค์น˜๋˜๋Š” ์•ฑ๋“ค์€ ์•Œ๋ฆผ ์ƒ์„ฑ ๊ถŒํ•œ์ด ์—†๋‹ค๋Š” ๊ฒƒ์„ ์•Œ์•˜๋‹ค. ํ•ด๋‹น ์ด์Šˆ๋Š” ํ…Œ์ŠคํŠธ ๋‹จ๋ง์ด Android 13 ๋‹จ๋ง์—, ํ…Œ์ŠคํŠธ ์•ฑ์ด ์‹ ๊ทœ๋กœ ์„ค์น˜๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์ด์—ˆ๋‹ค. Android 12๋Š” ๊ธฐ๋ณธ์œผ๋กœ ์•Œ๋ฆผ ์ƒ์„ฑ ๊ถŒํ•œ์ด ์žˆ์–ด์„œ ์ด๋Ÿฐ ์ด์Šˆ๋ฅผ ๋งŒ๋‚  ์ผ์ด ์—†์—ˆ๋‹ค. ์ •๋ง ์ž˜ ์„ค๋ช…ํ•ด์ฃผ์‹  ๊ธ€ https://codechacha.com/ko/android-13-notification-permission/ Android 13์—์„œ Notification ๊ถŒํ•œ ์š”์ฒญ, ์•Œ๋ฆผ ๋„์šฐ๊ธฐ Android 13์˜ ๋ณ€๊ฒฝ์‚ฌํ•ญ์œผ๋กœ, POST_NOTIFICATIONS ๊ถŒํ•œ์ด ๋„์ž…๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์•ฑ ๋™์ž‘์— ์–ด๋–ค ์˜..
[Android][Facebook Login] ํŽ˜์ด์Šค๋ถ ์•ฑ ๋ฏธ ์„ค์น˜ ์‹œ ๋กœ๊ทธ์ธ ๋ถˆ๊ฐ€ ์ด์Šˆ ์ œ๋ชฉ ๊ทธ๋Œ€๋กœ, ํŽ˜์ด์Šค๋ถ ์•ฑ์ด ์„ค์น˜๋˜์ง€ ์•Š์€ ๋‹จ๋ง์—์„œ ์•ฑ์˜ SNS ๋กœ๊ทธ์ธ์„ Facebook์œผ๋กœ ์‹œ๋„ํ•  ๊ฒฝ์šฐ, ๋กœ๊ทธ์ธ์ด ๋˜์ง€ ์•Š๋Š” ์ด์Šˆ์˜€๋‹ค. ํ”„๋กœ์ ํŠธ์˜ target Api level์€ 33์ด๊ณ , Android OS 13 ๋‹จ๋ง์—์„œ ๋ฐœ์ƒํ–ˆ๋‹ค. ์ด์ „์—๋Š” ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜๋˜ ์ด์Šˆ์˜€๋‹ค. Facebook Login sdk ๋ฒ„์ „์„ ํ™•์ธํ–ˆ๋‹ค. ์ด์Šˆ ๋ฐœ์ƒ facebook login sdk ๋ฒ„์ „์€ 14.1.1 ๋ณด๋‹ค ๋‚ฎ์•˜๋”ฐ. ๊ฐ„๋‹จํ•˜๊ฒŒ ํ•ด๊ฒฐํ•˜๊ฒŒ ๋๋‹ค. Facebook login sdk ๋ฒ„์ „์„ ์ตœ์‹ ์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์ด์Šˆ ํ•ด๊ฒฐ๋๋‹ค.
[Android][RecyclerView][NestedScrollView] ๋ฆฌ์‚ฌ์ดํด๋Ÿฌ๋ทฐ ์„ฑ๋Šฅ ํ–ฅ์ƒ ์‹œ์ž‘ ์ด๋ฒˆ ํ”„๋กœ์ ํŠธ์—์„œ '์Šต๊ด€ ๊ธฐ๋ฅด๊ธฐ'๋ผ๋Š” ํ…Œ๋งˆ๋กœ 3, 7, 21, 30, 66์ผ์˜ ์‚ฌ์ง„ ์ธ์ฆ ๋ฆฌ์ŠคํŠธ ํ™”๋ฉด์„ ๊ฐœ๋ฐœํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค. ํ™”๋ฉด์— ๊ธฐ๋ฅด๊ณ ์ž ํ•˜๋Š” ์Šต๊ด€์˜ ์ •๋ณด๋“ค๊ณผ ์ธ์ฆ ์‚ฌ์ง„ ๋ฆฌ์ŠคํŠธ(์ž‘์€ ์ •์‚ฌ๊ฐํ˜• ์ด๋ฏธ์ง€๋“ค์ด ๊ฐ€๋กœ 3 X ์„ธ๋กœ n์ค„๋กœ ๋…ธ์ถœ๋จ)๊ฐ€ ๋ชจ๋‘ ๋‚˜์™€์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, NestedScrollView๋ฅผ root view๋กœ ๋‘๊ณ  ํ™”๋ฉด layout์„ ๊ตฌ์„ฑํ–ˆ๋‹ค. ์Šต๊ด€๊ณผ ์ด๋ฏธ์ง€ ์ •๋ณด๋“ค์€ ํ™”๋ฉด ์ง„์ž… ์‹œ ์„œ๋ฒ„์—์„œ ๋ฐ›์•„์™€ ๋…ธ์ถœํ•œ๋‹ค. ๋ฟŒ๋“ฏํ•˜๊ฒŒ ๋‹ค ๋งŒ๋“ค๊ณ  ๋‚˜์„œ, ํ…Œ์ŠคํŠธ๋ฅผ ํ•˜๋Š”๋ฐ 66์ผ์น˜ ํ™”๋ฉด์€ ์„ฑ๋Šฅ์ด ๋„ˆ๋ฌด ๊ตฌ๋ ธ๋‹ค. ํ™”๋ฉด์ด ๋กœ๋“œ๋˜๋Š” ์‹œ๊ฐ„์ด ์˜ค๋ž˜ ๊ฑธ๋ ธ๋‹ค. ์ด๋ฅผ ๊ฐœ์„ ํ•˜๊ณ ์ž ๋งˆ์Œ ๋จน๊ณ  ์ž‘์—…์— ๋‚˜์„ ๋‹ค. ์™œ ์„ฑ๋Šฅ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š”๊ฐ€ NestedScrollView๊ฐ€ ์–ด๋–ป๊ฒŒ ๋Œ์•„๊ฐ€๋Š”์ง€ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค. https://stackoverflow..