• Importlarni optimallashtirishdan
  • 7 . Yechim kodini korib chiqing Korib chiqish uchun kod parchasi
  • Android studioni o`rganishni Boshlashdan oldin




    Download 2,85 Mb.
    bet7/8
    Sana06.12.2023
    Hajmi2,85 Mb.
    #112516
    1   2   3   4   5   6   7   8
    Bog'liq
    Android studioni o

    Eslatma:dp Siz keyingi yoʻlda zichlikka bogʻliq boʻlmagan piksellar ( ) haqida koʻproq bilib olasiz , lekin hozir koʻproq oʻqishni istasangiz “Layout – Material Design 3” maqolasiga qarang.
    @Composable
    fun Greeting(name: String, modifier: Modifier = Modifier) {
    Surface(color = Color.Cyan) {
    Text(
    text = "Hi, my name is $name!",
    modifier = modifier.padding(24.dp)
    )
    }
    }




    1. Ushbu importlarni import bayonoti bo'limiga qo'shing.

    Yangi importlarni alifbo tartibida joylashtirish uchun Importlarni optimallashtirishdan foydalaning .
    import androidx.compose.ui.unit.dp
    import androidx.compose.foundation.layout.padding

    Tabriklaymiz - siz Compose-da birinchi Android ilovangizni yaratdingiz! Bu juda katta yutuq. Turli xil ranglar va matnlar bilan o'ynashga biroz vaqt ajrating, uni o'zingiznikiga aylantiring!


    7 . Yechim kodini ko'rib chiqing 
    Ko'rib chiqish uchun kod parchasi
    package com.example.greetingcard

    import android.os.Bundle


    import androidx.activity.ComponentActivity
    import androidx.activity.compose.setContent
    import androidx.compose.ui.graphics.Color
    import androidx.compose.foundation.layout.fillMaxSize
    import androidx.compose.foundation.layout.padding
    import androidx.compose.material3.MaterialTheme
    import androidx.compose.material3.Surface
    import androidx.compose.material3.Text
    import androidx.compose.runtime.Composable
    import androidx.compose.ui.Modifier
    import androidx.compose.ui.tooling.preview.Preview
    import androidx.compose.ui.unit.dp
    import com.example.greetingcard.ui.theme.GreetingCardTheme

    class MainActivity : ComponentActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
    GreetingCardTheme {
    // A surface container using the 'background' color from the theme
    Surface(
    modifier = Modifier.fillMaxSize(),
    color = MaterialTheme.colorScheme.background
    ) {
    Greeting("Android")
    }
    }
    }
    }
    }

    @Composable


    fun Greeting(name: String, modifier: Modifier = Modifier) {
    Surface(color = Color.Cyan) {
    Text(text = "Hi, my name is $name!", modifier = modifier.padding(24.dp))
    }
    }

    @Preview(showBackground = true)


    @Composable
    fun GreetingPreview() {
    GreetingCardTheme {
    Greeting("Meghan")
    }
    }


    8 . Xulosa 
    Siz Android Studio haqida bilib oldingiz va Compose bilan birinchi Android ilovangizni yaratdingiz, ajoyib ish!
    Ushbu kodlash kitobi “Yozish bilan Android asoslari” kursining bir qismidir . Ilovangizni emulyatorda yoki jismoniy qurilmada qanday ishga tushirishni oʻrganish uchun ushbu yoʻldagi keyingi kod laboratoriyalarini koʻrib chiqing .

    Download 2,85 Mb.
    1   2   3   4   5   6   7   8




    Download 2,85 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Android studioni o`rganishni Boshlashdan oldin

    Download 2,85 Mb.