class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyCardTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
}
}
}
}
}
@Composable
fun Image_BackGround(message: String, modifier: Modifier = Modifier){
val image = painterResource(R.drawable.miku)
Image(
painter = image,
contentDescription = null,
contentScale = ContentScale.Crop,
alpha = 0.8F
)
}
@Composable
fun Head_Image(message: String, modifier: Modifier = Modifier){
val image2 = painterResource(id = R.drawable.image_1705730544646)
Image(
painter = image2,
contentDescription = null,
modifier = Modifier
.size(100.dp) // 設(shè)置圖片尺寸
.offset(120.dp, 50.dp)
)
}
@Composable
fun Greeting(message: String, modifier: Modifier = Modifier) {
Text(
text = "$message",
modifier = modifier
.offset(110.dp, 320.dp)
// 設(shè)置位置偏移,例如橫向偏移 50.dp,縱向偏移 20.dp
)
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
MyCardTheme {
Image_BackGround(message = "123")
Head_Image("Happy Birthday Sam!")// 設(shè)置圖片位置偏移) // 設(shè)置圖片位置偏移)
Greeting(message = "Name:HumanPlug\n School:ECUST\n Blog:\nhttps://www.cnblogs.com/\nhumanplug")
}
}
文章來源:http://www.zghlxwxcb.cn/news/detail-812870.html
本文由博客一文多發(fā)平臺 OpenWrite 發(fā)布!文章來源地址http://www.zghlxwxcb.cn/news/detail-812870.html
到了這里,關(guān)于簡易Android名片制作的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!