简易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 发布!

相关推荐
用户2018792831671 小时前
浅谈Android PID与UID原理
android
TimeFine1 小时前
Android AWS KVS WebRTC 通话声道切换到媒体音乐声道
android
用户2018792831672 小时前
Android文件下载完整性保证:快递员小明的故事
android
用户2018792831672 小时前
自定义 View 的 “快递失踪案”:为啥 invalidate () 喊不动 onDraw ()?
android
没有了遇见2 小时前
Android 稀奇古怪系列:新版本签名问题-Algorithm HmacPBESHA256 not available
android
小妖怪的夏天3 小时前
react native android设置邮箱,进行邮件发送
android·spring boot·react native
东风西巷3 小时前
Avast Cleanup安卓版(手机清理优化) 修改版
android·学习·智能手机·软件需求
用户2018792831673 小时前
Android断点续传原理:小明的"读书笔记"故事
android
用户2018792831674 小时前
ART 内存模型:用 “手机 APP 小镇” 讲明白底层原理
android
liulangrenaaa4 小时前
Android NDK 命令规范
android