我正在尝试运行 Android 材料设计,同样取自下面https://github.com/material-components/material-components-android
但出现这些错误:
failed
:lib:packageDebugResources
tokens.xml
Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_sys_color_dark_surface_tint">?attr/colorPrimary</macro>'
fab_tokens.xml
Can't determine type for tag '<macro name="m3_comp_fab_primary_container_color">?attr/colorPrimaryContainer</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_comp_switch_selected_icon_color">?attr/colorOnPrimaryContainer</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_sys_motion_path">linear</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_sys_shape_corner_full_family">rounded</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_ref_typeface_brand_regular">sans-serif</macro>'
/Users/mac/AndroidStudioProjects/material-components-android/lib/java/com/google/android/material/bottomappbar/res/values/tokens.xml: Error: Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'
Run Code Online (Sandbox Code Playgroud) 在使用基于视图的系统时,我们可以使用以下代码来协调颜色。
MaterialColors.harmonizeWithPrimary(context, colorToHarmonize)
Run Code Online (Sandbox Code Playgroud)
在完全迁移到 Jetpack Compose 并且所有颜色值都存储在文件中的项目中Color.kt,如何在运行时对颜色应用协调?
android android-jetpack-compose material-you android-jetpack-compose-material3 material3
我正在使用 Card 可组合项,我希望它的颜色为白色。
但是当我向它添加一些高度时,它会将颜色更改为更像primaryContainer 颜色。
我看过文档,其中有一些称为“elevationOverlay”的东西。但找不到说明如何使用它的示例。
这是我的代码:
Card(
modifier = Modifier.padding(top = 16.dp),
colors = CardDefaults.cardColors(containerColor = White),
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
) {
}
Run Code Online (Sandbox Code Playgroud)
我确实知道我可以使用提升卡代替卡,但提升卡也存在同样的问题。
另外,这是一个特殊情况,所以我手动应用颜色
在我的应用程序栏中,标题显示为白色文本,但图标是深灰色或其他颜色。我也想让图标变成白色。
但图标主题中的颜色没有任何效果!
直接添加到 AppBar 时不会...
Scaffold(
appBar: AppBar(automaticallyImplyLeading: false,
actionsIconTheme: IconThemeData(color: Colors.white),
iconTheme: IconThemeData(color: Colors.white),
Run Code Online (Sandbox Code Playgroud)
而且也不在主题中...
appBarTheme: AppBarTheme(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
actionsIconTheme: IconThemeData(color: Colors.white),
iconTheme: IconThemeData(color: Colors.white),
),
Run Code Online (Sandbox Code Playgroud)
我想让主题发挥作用!无法在图标上单独设置颜色。
我究竟做错了什么?Material 3 真的准备好投入生产了吗?
谢谢!
注意:这是材料 3 的问题!在材质 2 中,一切都按预期进行!
android-appbarlayout flutter flutter-appbar flutter-theme material3
link1(屏幕截图):https://flutter.github.io/samples/web/material_3_demo/#/
\nlink2(文档):https://api.flutter.dev/flutter/material/FilledButton-class.html#material.FilledButton.1
\n扑医生
\n[\xe2\x9c\x93] Flutter(频道稳定,3.3.10,在 macOS 12.5.1 21G83 darwin-arm 上,区域设置 ko-KR)\n\xe2\x80\xa2 Flutter 版本 3.3.10,频道稳定在 / Users/username/development/flutter\n\xe2\x80\xa2 上游存储库https://github.com/flutter/flutter.git \n\xe2\x80\xa2 框架修订版 135454af32(8 天前),2022-12 -15 07:36:55 -0800\n\xe2\x80\xa2 引擎修订版 3316dd8728\n\xe2\x80\xa2 Dart 版本 2.18.6\n\xe2\x80\xa2 DevTools 版本 2.15.0
\n我想使用填充按钮
\n我尝试像官方文档代码一样导入材质包,但是找不到FilledButton类。
\n该小部件尚未实现?
\n[编辑]
\n我找到了一种使用 FilledButton 的方法
\n[在终端中...]
\nflutter channel master\nflutter pub upgrade\nRun Code Online (Sandbox Code Playgroud)\n然后,可以找到FilledButton类
\n我开始学习 Jetpack Compose,如何使用 Material3 依赖项实现一个简单的小吃栏看起来令人困惑。
文档显示我需要一个脚手架,并且它需要带有填充的内容(?)。我需要将屏幕可组合放在 lambda 脚手架中吗?如何将消息文本传递到 Snackbar?我有一个简单的流收集器,用于来自视图模型的事件,我想将错误文本传递到小吃栏。
Test()
LaunchedEffect(Unit) {
viewModel.loginEvent.collect {
when (it) {
is LoginViewModel.LoginEvent.Error -> {
// show snackbar with it.error
}
is LoginViewModel.LoginEvent.Success -> {
//
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
@Composable
fun Test() {
Box(modifier = Modifier.fillMaxSize()) {
//my composable screen
}
Run Code Online (Sandbox Code Playgroud) android snackbar android-jetpack-compose android-jetpack-compose-material3 material3
我目前正在 Compose 中开发一个使用 Material 3 中的 LargeTopAppBar 的标题。问题是,标题不是很可定制,滚动动画(使用nestedScroll)也不是。我想在标题下方添加一个副标题,一旦 AppBar 折叠,该副标题将不会显示在小标题中。我还想知道是否有办法自定义标题的实际动画。
我知道 Material 3 仍处于 Alpha 阶段,但我很好奇是否有一些解决方案或解决方法。提前致谢!
android android-jetpack-compose android-jetpack-compose-material3 material3
我想删除所选项目后面的蓝色椭圆形颜色。我怎样才能做到这一点?
NavigationBarItem(
selected = selected,
onClick = onClick,
icon = if (selected) selectedIcon else icon,
modifier = modifier,
enabled = enabled,
label = label,
alwaysShowLabel = alwaysShowLabel,
colors = NavigationBarItemDefaults.colors(
selectedIconColor = AppDefaults.navigationSelectedItemColor(),
unselectedIconColor = AppDefaults.navigationContentColor(),
selectedTextColor = AppDefaults.navigationSelectedItemColor(),
unselectedTextColor = AppDefaults.navigationContentColor(),
indicatorColor = AppDefaults.navigationIndicatorColor()
)
)
Run Code Online (Sandbox Code Playgroud)
android android-jetpack-compose android-jetpack-compose-material3 material3
我有一个用 Jetpack Compose 编写的 Android 应用程序。我正在尝试使用应用程序中定义的 colorScheme 设置图标颜色,但它不起作用。
下面是我的代码。
颜色.kt
import androidx.compose.ui.graphics.Color
val green = Color(0xFF61FF67)
Run Code Online (Sandbox Code Playgroud)
主题.kt
private val MesColorDark = darkColorScheme(
primary = green,
secondary = green,
tertiary = green,
surface = green
)
private val MesColorLight = lightColorScheme(
primary = green,
secondary = green,
tertiary = green,
surface = green
)
@Composable
fun MesTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val mesColorScheme =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val context = LocalContext.current
if …Run Code Online (Sandbox Code Playgroud) android material-design android-jetpack-compose android-jetpack-compose-material3 material3
我正在尝试使用新的 Material 3 搜索栏(https://github.com/material-components/material-components-android/blob/master/docs/components/Search.md)。所以我是这样实现的
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.search.SearchBar
android:id="@+id/searchBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/searchbarHint"/>
</com.google.android.material.appbar.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
围绕这个我有一个LinearLayoutin a CoordinatorLayout。我在正确的位置看到搜索栏,并且我实现的点菜单也可以工作,但是当我单击搜索栏时它没有反应。这就像单击一个按钮(我看到单击反馈)。
我只是它显示了一个键盘,这样我就可以输入搜索查询。但事实并非如此。
material3 ×10
android ×8
android-jetpack-compose-material3 ×5
flutter ×2
material-components-android ×1
material-you ×1
snackbar ×1