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

相关推荐
独自破碎E1 小时前
【BISHI9】田忌赛马
android·java·开发语言
代码s贝多芬的音符2 小时前
android 两个人脸对比 mlkit
android
darkb1rd4 小时前
五、PHP类型转换与类型安全
android·安全·php
gjxDaniel4 小时前
Kotlin编程语言入门与常见问题
android·开发语言·kotlin
csj504 小时前
安卓基础之《(22)—高级控件(4)碎片Fragment》
android
峥嵘life5 小时前
Android16 【CTS】CtsMediaCodecTestCases等一些列Media测试存在Failed项
android·linux·学习
stevenzqzq6 小时前
Compose 中的状态可变性体系
android·compose
似霰6 小时前
Linux timerfd 的基本使用
android·linux·c++
darling3318 小时前
mysql 自动备份以及远程传输脚本,异地备份
android·数据库·mysql·adb
你刷碗8 小时前
基于S32K144 CESc生成随机数
android·java·数据库