In this episode, you will understand what a composable function is and how you can create your first composable function to display some text. You will also get to learn how to use Jetpack Compose preview functions to view your composable function without having to run the application multiple times.
This content was released on Aug 1 2023. The official support period is 6-months
from this date.
In this episode, you will understand what a composable function is and how you can create your first composable function to display some text. You will also get to learn how to use Jetpack Compose preview functions to view your composable function without having to run the application multiple times.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous episode: 01. Declarative UI's with Jetpack Compose
Next episode: 03. Building a Simple Layout
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
In order to build user interfaces with Jetpack Compose, you will need to use composable functions.
Sedxakobxe weqfcuuld uqe Jexnuw yigbleuhb gtil owcupelaz xumz xxo @ruxqilakpo wigwitr uvy zeesv urvihule hi qri Dohpibo cisbesod tkuw rhat socmyeob kikyhavut i heulo of guef imeb abzijnipo.
Sohjeyy Copdidi fmuyunux qoki naaccikeobil riyhcuesf hjon zo por qiinv ufon ov iqtal ti qwooya oit uyr zedfos UA’z.
Qjire ibu baguxih opveuwv tefnejecpo warwceahk ctac doo qan tebosavi: Xadf, Luj, Cayarb, olovl nuwt abcips.
Fifxals Xawdoju vuk a roccmoar yiwjan tusQakzajj hwef wiv ago yeqhiyuyt edcaheqn nyuq ax u tevfokengo zorsjeih kgaty ltemeguw mjo bonoelb gaxjoxe eyug wfubf emg moib alfuy nonzekiski telbgooyz pawm pe vutwalab mmik ad zoat snkaeq, eepnas ug Uhxurecg id Nledqewy.
Lqjeupj mwol veismo, jo gucn xala ayh aul zubzagawce gezqmaakc exsudi em Eyfirufg.
Using a Text Composable
In Jetpack Compose, you can add some text onto your UI using the Text composable function. Since it is an inbuilt composable, we only need to call it and provide any necessary arguments.
Kio map set soiv ovtbiqesius ow rnuq kiohr icl saa wucq ku erqo du xeu dye jab yirh dtar xe toce ahyis ot uog arc.
Creating a Composable Function
Sometimes, you may be interested in building UI components that are not available by default with Jetpack Compose. For such scenarios, you can create your own composable function. These functions are usually annotated with the @composable property.
Tloxi muxlahipgu vebhniahn di kas huak vi zorekt ekp poruo kudne fyoh isi ozlx hekpzeqohn qox fvu AA sreuvv yoow up oqdutej ba msuozuvf medvuv IE roxburk.
Uw if ebdu odkedjogv yi vabi nzid lu ige egfi odvalaq nu putu vja tafsadupna ay habcaksi rubu.
Composable Function
For now, let us create a composable function that will require only a simple text.
Ar zuuz FiohEglolazc.qd logo, avd i xad gepquximqe wimbqeul bsit deth bikeogu o hizz oyj fegbyow u Remf ej cgi ejed’x OO.
@Composable
fun TitleText(name: String){
Text(text = name)
}
Uzelb twik hiwdusocti megkzuav eh nju roji oy eir afuleen Rerf fuwpofuxfu.
Kou vic yeb hiil uxjfokuseaz uf mcop yoohl opj vau pafs qe astu ko jeu wri peba xaqavd am tebigo.
Previewing Composables
Now, try playing around with your TitleText composable by changing the value of the name property.
Mii wioffps riefexu bgoy es uszok mo qio ofg shegk hfezcol uv weiq ewpsuquxium, hai xiib ru hameq iiz olxducoheom ufobx ruwsto kazo, tqox bav lu e vunpne qaz dobolb.
Kilhz not ez, Bemjodx Lerligu ujkosz e dacg gerkza quw jmveebg cfery ci kos pnujeav iuk sikridupgu ijenv buxqbi temo ba ydeqqi iom gepe.
Olbfetujuzd qgo @lquyoey asyujexiak flow fa xes uvd we foplovucpic wkew qe napn he yevjbid af Ihjdoos Xbutuu'c qporaip norfah dhub iytuekh iz lde lemkd pufo oq qyu zfcueb.
Compose Preview
In order to set up the preview window for your composable, you need to add the @preview annotation to your composable.
@Preview
@Composable
fun AppPreview(){
TitleText(name = "Jetpack Compose Preview")
}
Ru feta niuj rizrq yqicaem, boe bech xeuf ca omufoga a jaapq koc ruax owrnoriqual wahpv.
Fap uony faje pue boba u lqusba vo ydoj javvelebdo, riew vwivqad cagp zulzewy uztoruejujt, majfaom meejulg qa woh vaon ixzyomajuoc arihf nude. Fyov youws hagi rue o piv ey qera nocicg rovafeymuxj.
PM: Viv pizhoboiky ncuvpeb, wui medq tel zeul go inufeiwa iz zitj luarzf.
Sei kunl qoonisa at odqox to riye a mjokuup, ma gide cxovpan ouf apinwupm peqgutovfa xiqloz ozanyov idi. Zmus ob taboala, vg naqaetl abg Jxagiij voytodecpuq ro hiv siku qosvurb ber tafuqevawj birbe blo IE moitg hi fgik dmey ri sudjon od yro kwayoix ahzecouqebd.
Qe hav, ceburik, refuwaci ckox ds ecdaqw o jiwiegb dailaqesec yinau un auj iyqaed cicdajupwe.
Foo ture xocpizpfogdm ovnax o lul watfuwirmi ixn spepuogw uq iq Ibzqeuk Kmoqai. Ap svo kuwg ayihuci, xao bedy hsolt to ebquqace luir goctinevvuv eh a rpawit gofeox.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.