简体   繁体   English

为什么我的 JetPack 撰写文本这么大(材料设计)

[英]Why is my JetPack compose text so big (material design)

I am practicing Jetpack compose, by making a simple Application with multiple destinations (screen), I happen to be referencing an Android Developer codelab , for a destination.我正在练习 Jetpack 组合,通过制作一个具有多个目的地(屏幕)的简单应用程序,我碰巧正在为一个目的地引用一个Android Developer codelab But the final looks is very different from the codelab's, most noticably the fonts are way bigger on my code than it is in the codelab even though I'm using the same font style, h3, and I've tried as much as possible to be using the same or a more recent dependecency than was used in the codelab.但最终的外观与 codelab 的非常不同,最值得注意的是 fonts 在我的代码中比在 codelab 中的要大得多,即使我使用相同的字体样式 h3,并且我已经尽可能多地尝试使用与代码实验室中使用的相同或更新的依赖关系。

Here's what I mean.这就是我的意思。

The Android Developer look; Android 开发者外观;

Android 开发者外观

And my code looks like;我的代码看起来像;

我的代码看起来

Here's the Android Developer compose code;这是 Android 开发人员编写代码;

@Composable
fun FavoriteCollectionCard(
    @StringRes text: Int,
    @DrawableRes drawable: Int,
    modifier: Modifier = Modifier
) {
    Surface(
        shape = MaterialTheme.shapes.small,
        modifier = modifier
    ) {
        Row(
            verticalAlignment = Alignment.CenterVertically,
            modifier = Modifier
                .width(192.dp)
        ) {
            Image(
                painter = painterResource(drawable),
                contentDescription = null,
                contentScale = ContentScale.Crop,
                modifier = Modifier
                    .size(56.dp)
            )
            Text(
                text = stringResource(text),
                style = MaterialTheme.typography.h3,
                modifier = Modifier.padding(horizontal = 16.dp)
            )
        }

    }
}

Here's the Android Developer compose code;这是 Android 开发人员编写代码;

@Composable
fun DashBoardCard(
    @StringRes text: Int,
    @DrawableRes drawable: Int,
    modifier: Modifier = Modifier
) {
    Surface(
        shape = MaterialTheme.shapes.small,
        modifier = modifier
    ) {
        Row(
            verticalAlignment = Alignment.CenterVertically,
            modifier = Modifier
                .width(192.dp)
        ) {
            Image(
                painter = painterResource(drawable),
                contentDescription = null,
                contentScale = ContentScale.Crop,
                modifier = Modifier
                    .size(56.dp)
            )
            Text(
                text = stringResource(text),
                style = MaterialTheme.typography.h3,
                modifier = Modifier.padding(horizontal = 16.dp)
            )
        }

    }
}

As I said before I tried to make the dependencies the same or more recent, I don't want this question to be anymore bucky, but I'm just going to add a few dependency, please whatever you need I'm happy to provide.正如我在尝试使依赖项相同或更新之前所说的那样,我不希望这个问题不再是巴克的,但我只是要添加一些依赖项,请无论您需要什么,我很乐意提供.

Android Developer Codelab dependency; Android 开发者 Codelab 依赖;

ext {
        compose_version = '1.2.0-alpha05'
    }

plugins {
    id 'com.android.application' version '7.2.0' apply false
    id 'com.android.library' version '7.2.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
    id 'com.diffplug.spotless' version '6.3.0'
}

My dependency;我的依赖;

ext {
        compose_version = '1.2.0-alpha05'
        nav_version = "2.5.1"
    }

plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}

EDIT;编辑; I will greatly appreciate any type of help, pointers, corrections whatever help you can offer, I will be much greatful.我将不胜感激任何类型的帮助、指点、更正,无论您能提供什么帮助,我都会非常感激。

Thanks a lot for your help, in advance.非常感谢您的帮助,提前。

Are you using same implementation of MaterialTheme as they are and are you wrapping your screen in it?您是否使用与它们相同的 MaterialTheme 实现,并且您是否将屏幕包裹在其中? Their implementation is here and h3 is defined here like this:他们的实现在这里h3 在这里定义如下:

h3 = TextStyle(
    fontWeight = FontWeight.Bold,
    fontSize = 14.sp,
    letterSpacing = 0.sp
)

Your image definitely doesn't look like 14sp, it also looks like different color, so I guess you are missing the theme completely.你的图像绝对不像 14sp,它看起来也像不同的颜色,所以我猜你完全错过了主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的 Jetpack Compose Text 不重组而 TextField 重组 - Why my Jetpack Compose Text does not recomposed while TextField does 为什么我的文本在此 Android Jetpack Compose 列表的每一行中都被剪掉了? - Why is my text clipped in each row of this Android Jetpack Compose list? 使用 Material Design 3 时如何在 Jetpack Compose 中定义按钮的形状 - How to define shape for Button in Jetpack compose when using Material design 3 调整 Jetpack Compose 中 Material Design 3 组件的色调提升? - Adjust Tonal Elevation for Material Design 3 Components in Jetpack Compose? Jetpack Compose - 我的 Text() 中的版式自定义不受影响 - Jetpack Compose - Typography customization not affected in my Text() 为什么 Jetpack Compose 不将按钮中的文本大写? - Why does Jetpack Compose not capitalize text in buttons? 为什么 jetpack compose elevation 剪辑我的影子? - Why jetpack compose elevation clip my shadow? 在 Jetpack Compose with Material3 的应用栏中显示文本字段 - Showing a text field in the app bar in Jetpack Compose with Material3 如何旋转和放置文本,以便一些旋转而一些不在 Jetpack Compose 中 - how to rotate and place text so that some is rotated and some is not in jetpack compose 为什么 Android Jetpack Compose 制作的 UI 加载这么慢? - Why is the UI made by Android Jetpack Compose loaded so slow?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM