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

相关推荐
笨鸭先游3 小时前
前台--Android开发
android
fareast_mzh3 小时前
Lightweight App Alternatives
android
pq113_67 小时前
OrangePi Zero 3学习笔记(Android篇)4 - eudev编译(获取libudev.so)
android·笔记·学习
鸿蒙布道师11 小时前
鸿蒙NEXT开发动画案例3
android·ios·华为·harmonyos·鸿蒙系统·arkui·huawei
鸿蒙布道师11 小时前
AI原生手机:三大技术阵营的终极对决与未来展望
android·人工智能·ios·华为·智能手机·ai-native·hauwei
每次的天空12 小时前
移动应用开发:自定义 View 处理大量数据的性能与交互优化方案
android·java·学习·交互
Huang兄13 小时前
Android 项目中配置了多个 maven 仓库,但依赖还是下载失败,除了使用代理,还有其他方法吗?
android·gradle·maven
snail20121113 小时前
Flutter接入ProtoBuff和原生Android通信【性能最优】
android·flutter
難釋懷14 小时前
Android开发-常用布局
android·gitee
墨菲斯托88815 小时前
fakebook
android