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

相关推荐
casual_clover33 分钟前
Android Studio 解决首次安装时下载 Gradle 慢问题
android·ide·android studio
天天爱吃肉82181 小时前
新能源汽车热管理核心技术解析:冬季续航提升40%的行业方案
android·python·嵌入式硬件·汽车
快乐觉主吖2 小时前
Unity的日志管理类
android·unity·游戏引擎
明月看潮生2 小时前
青少年编程与数学 01-011 系统软件简介 06 Android操作系统
android·青少年编程·操作系统·系统软件·编程与数学
snetlogon202 小时前
JDK17 Http Request 异步处理 源码刨析
android·网络协议·http
消失的旧时光-19433 小时前
Android USB 通信开发
android·java
吃汉堡吃到饱3 小时前
【Android】浅析View.post()
android
咕噜企业签名分发-淼淼3 小时前
开发源码搭建一码双端应用分发平台教程:逐步分析注意事项
android·ios
betazhou4 小时前
mariadb5.5.56在centos7.6环境安装
android·数据库·adb·mariadb·msyql
doublelixin9 小时前
AOSP (Android11) 集成Google GMS三件套
android