小编Jee*_*cha的帖子

如何使用 jetpack compose 制作自定义通知视图?

我想制作一个自定义通知视图,其中的内容会定期更新。自定义视图可能包含操作按钮。在android文档中,我们可以使用XML布局文档创建自定义视图:https://developer.android.com/training/notify-user/custom-notification

// Get the layouts to use in the custom notification
val notificationLayout = RemoteViews(packageName, R.layout.notification_small)
val notificationLayoutExpanded = RemoteViews(packageName, R.layout.notification_large)

// Apply the layouts to the notification
val customNotification = NotificationCompat.Builder(context, CHANNEL_ID)
        .setSmallIcon(R.drawable.notification_icon)
        .setStyle(NotificationCompat.DecoratedCustomViewStyle())
        .setCustomContentView(notificationLayout)
        .setCustomBigContentView(notificationLayoutExpanded)
        .build()
Run Code Online (Sandbox Code Playgroud)

那么我们可以使用 jetpack compose 制作自己的自定义通知视图吗?

android android-layout android-notifications android-view android-jetpack-compose

8
推荐指数
1
解决办法
3872
查看次数

如何使用自定义样式更改 TextDecoration.Underline?

我想将自定义下划线样式应用于带下划线的文本。我们可以在里面改变吗TextDecoration.underline

textStyle = MaterialTheme.typography.titleMedium.copy(
    textAlign = TextAlign.Start,
    fontWeight = FontWeight.W600,
    color = color,
    textDecoration = TextDecoration.Underline
)
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose android-compose-textfield

8
推荐指数
1
解决办法
4927
查看次数

在jetpack compose中显示时如何使文本数字动画化?

我想用数字显示文本,我想要实现的是在显示文本时为该文本设置动画。动画是应该将计数器从零增加到目标值。我尝试使用animateIntAsState但它不起作用。

这就是我累的状态:

 val daysCounter by animateIntAsState(
        targetValue = days ,
        animationSpec = tween(
            durationMillis = 5000,
            easing = FastOutSlowInEasing
        )
    )
Run Code Online (Sandbox Code Playgroud)

和文字:

        Text(
                text = "$daysCounter",
                fontSize = 40.sp,
                color = MaterialTheme.colors.onPrimary,
                fontWeight = FontWeight.Bold
            )
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose android-jetpack-compose-text jetpack-compose-animation

7
推荐指数
1
解决办法
3851
查看次数

如何在jetpack compose中使文本变得太粗?

使用Jetpack Compose Text()时,我无法更改fontWeightmore thanFontWeight.W600FontWeight.W500. 除了这两个之外,没有像 、 等应用FontWeight.W700FontWeight.BoldFontWeight(550)试图创建太暗的文本,但根本无法实现。注意:我使用的是来自谷歌可下载字体的Roboto字体和.material theme 3

One example of text code:-

Text(
   modifier = Modifier.padding(top = 4.dp),
   text = "This should be too bold",
   style = MaterialTheme.typography.titleSmall,
   fontWeight = FontWeight.Black,
)
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose android-compose-textfield

6
推荐指数
1
解决办法
4558
查看次数

我在使用jetpack compose的material3中找不到ModalBottomSheetLayout?

更新

我们终于在 Material3 中拥有了 BottomSheet,遵循这个 ans链接

最近我使用 `material3` 和 `jetpack compose` 创建了一个项目,但是当我尝试导入 `ModalBottomSheetLayout` 但我找不到它。是否有“material3 中的替代品”?

在以前的材料版本中,我们确实喜欢:-

ModalBottomSheetLayout(sheetContent = ) {
        
    }
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose android-bottomsheetdialog android-jetpack-compose-material3

5
推荐指数
1
解决办法
4720
查看次数

如何在jetpack compose中创建自定义rememberState?

我们可以创建自己的custom rememberState喜欢的吗rememberModalButtomSheetSTate()?另外,我想将可组合项存储在 RememberState 中,并能够使用此状态设置和访问可组合项。喜欢rememberState.setCompose = @ComposablerememberState.getComposable

android android-jetpack-compose

3
推荐指数
1
解决办法
1501
查看次数

在 NextJS/ReactJS 中获取当前位置的地理位置坐标 [ latitude, longitude ]

我需要用户当前位置latitude,来相应地显示帖子,我正在使用 next.js 任何人都可以帮助我吗?longitude

geolocation userlocation reactjs next.js

0
推荐指数
1
解决办法
5813
查看次数