Upload files to "/"
tugas 2 android studio
This commit is contained in:
		
						commit
						90ea628f8d
					
				
							
								
								
									
										70
									
								
								MainActivity.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								MainActivity.kt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,70 @@
 | 
				
			|||||||
 | 
					package com.example.myapplication
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle
 | 
				
			||||||
 | 
					import androidx.activity.ComponentActivity
 | 
				
			||||||
 | 
					import androidx.activity.compose.setContent
 | 
				
			||||||
 | 
					import androidx.activity.enableEdgeToEdge
 | 
				
			||||||
 | 
					import androidx.compose.foundation.background
 | 
				
			||||||
 | 
					import androidx.compose.foundation.layout.Box
 | 
				
			||||||
 | 
					import androidx.compose.foundation.layout.fillMaxSize
 | 
				
			||||||
 | 
					import androidx.compose.foundation.layout.padding
 | 
				
			||||||
 | 
					import androidx.compose.material3.Scaffold
 | 
				
			||||||
 | 
					import androidx.compose.material3.Text
 | 
				
			||||||
 | 
					import androidx.compose.runtime.Composable
 | 
				
			||||||
 | 
					import androidx.compose.ui.Modifier
 | 
				
			||||||
 | 
					import androidx.compose.ui.graphics.Color
 | 
				
			||||||
 | 
					import androidx.compose.ui.tooling.preview.Preview
 | 
				
			||||||
 | 
					import com.example.myapplication.ui.theme.MyApplicationTheme
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class MainActivity : ComponentActivity() {
 | 
				
			||||||
 | 
					    override fun onCreate(savedInstanceState: Bundle?) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState)
 | 
				
			||||||
 | 
					        enableEdgeToEdge()
 | 
				
			||||||
 | 
					        setContent {
 | 
				
			||||||
 | 
					            MyApplicationTheme {
 | 
				
			||||||
 | 
					                Scaffold(
 | 
				
			||||||
 | 
					                    modifier = Modifier.fillMaxSize()
 | 
				
			||||||
 | 
					                ) { innerPadding -> // <-- gunakan innerPadding
 | 
				
			||||||
 | 
					                    // letakkan Box/Surface agar background dan padding saling berurutan
 | 
				
			||||||
 | 
					                    Box(
 | 
				
			||||||
 | 
					                        modifier = Modifier
 | 
				
			||||||
 | 
					                            .fillMaxSize()
 | 
				
			||||||
 | 
					                            .background(Color(0xFF0D47A1)) // contoh biru gelap; bisa pake Color.Blue juga
 | 
				
			||||||
 | 
					                            .padding(innerPadding) // <-- pakai innerPadding di sini
 | 
				
			||||||
 | 
					                    ) {
 | 
				
			||||||
 | 
					                        Greeting(
 | 
				
			||||||
 | 
					                            name = "Android",
 | 
				
			||||||
 | 
					                            modifier = Modifier // kalau mau beri margin/padding lagi, tambahkan di sini
 | 
				
			||||||
 | 
					                        )
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Composable
 | 
				
			||||||
 | 
					fun Greeting(name: String, modifier: Modifier = Modifier) {
 | 
				
			||||||
 | 
					    Text(
 | 
				
			||||||
 | 
					        text = "Hello $name!",
 | 
				
			||||||
 | 
					        color = Color.White,
 | 
				
			||||||
 | 
					        modifier = modifier
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Preview(showBackground = true)
 | 
				
			||||||
 | 
					@Composable
 | 
				
			||||||
 | 
					fun GreetingPreview() {
 | 
				
			||||||
 | 
					    MyApplicationTheme {
 | 
				
			||||||
 | 
					        Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
 | 
				
			||||||
 | 
					            Box(
 | 
				
			||||||
 | 
					                modifier = Modifier
 | 
				
			||||||
 | 
					                    .fillMaxSize()
 | 
				
			||||||
 | 
					                    .background(Color(0xFF0D47A1))
 | 
				
			||||||
 | 
					                    .padding(innerPadding)
 | 
				
			||||||
 | 
					            ) {
 | 
				
			||||||
 | 
					                Greeting("Lalu Angga")
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user