简易Android名片制作

复制代码
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) // 设置图片尺寸
            .offset(120.dp, 50.dp)
    )
}

@Composable
fun Greeting(message: String, modifier: Modifier = Modifier) {
    Text(
        text = "$message",
        modifier = modifier
            .offset(110.dp, 320.dp)
            // 设置位置偏移,例如横向偏移 50.dp,纵向偏移 20.dp
    )
}



@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    MyCardTheme {
        Image_BackGround(message = "123")
        Head_Image("Happy Birthday Sam!")// 设置图片位置偏移) // 设置图片位置偏移)
        Greeting(message = "Name:HumanPlug\n   School:ECUST\n          Blog:\nhttps://www.cnblogs.com/\nhumanplug")
    }
}

本文由博客一文多发平台 OpenWrite 发布!

相关推荐
带娃的IT创业者6 小时前
围墙花园的隐形锁:当 reCAPTCHA 拒绝了“去谷歌化”的 Android 用户
android·隐私安全·人机验证·recaptcha·去谷歌化·grapheneos
awu的Android笔记7 小时前
Android 用户态实现 TCP 代理:从 SYN 到 FIN 的完整生命周期
android·tcp/ip
Geek_Vison7 小时前
技术实践:保险健康APP引入第三方小程序实战,如何构建一个安全可控的沙箱环境~
android·安全·小程序·uni-app·mpaas
2501_915918418 小时前
Python如何抓取HTTPS请求包的完整教程与代码示例
android·ios·小程序·https·uni-app·iphone·webview
. . . . .8 小时前
android开发
android
程序员看世界8 小时前
Kotlin协程是如何实现优先级机制的
android·kotlin
Carson带你学Android8 小时前
Kotlin放大招!官方 Skills 直接喂出「专家级」代码
android·前端·kotlin
Coffeeee8 小时前
一个kotlin的Smart cast导致的编译问题
android·前端·kotlin
plainGeekDev8 小时前
XML 布局 → Compose 声明式 UI
android·java·kotlin
杊页8 小时前
系列一:架构思想进阶 | 第2篇 分层架构实战:四层拆分、单向依赖与架构防腐
android