我正在创建一个Android应用程序,我正在使用AndroidX库和Material设计主题.我的应用主题styles.xml
是:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我从库中有以下FAB按钮:
<com.leinardi.android.speeddial.SpeedDialView
android:id="@+id/work_log_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
app:layout_behavior="@string/speeddial_scrolling_view_snackbar_behavior"
app:sdMainFabClosedSrc="@drawable/ic_add_white_24dp"
app:sdOverlayLayout="@id/overlay" />
Run Code Online (Sandbox Code Playgroud)
并尝试了默认的FAB:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:src="@drawable/ic_add_white_24dp"
android:layout_margin="16dp" />
Run Code Online (Sandbox Code Playgroud)
没有图标的颜色(矢量可绘制),FAB内的图标(来自库和默认图标)总是黑色.我已经将问题缩小到材料设计主题,因为使用旧的Theme.AppCompat.Light.DarkActionBar
而不是新Theme.MaterialComponents.Light.DarkActionBar
的FAB内的图标获得原始矢量drawable的颜色.
有谁知道为什么会发生这种情况以及如何解决这个问题?
android android-theme material-design floating-action-button androidx
我禁用了intellij对话框,要求将Java代码转换为Kotlin代码,从Java到Kotlin的复制粘贴代码,认为它总能在不询问的情况下转换,但现在它永远不会转换.如何再次启用此对话框?我找不到任何办法,现在IDE不再将Java转换为Kotlin了.
今天,我开始得到的错误Unable to load class 'kotlin.collections.CollectionsKT'
(如显示在此图片)每次我尝试摇篮同步我的项目时间。我在这个错误上找不到任何东西,唯一的解决方案似乎是在 Intellij 上禁用 kotlin 插件。我的一些项目没有 kotlin,但其他项目有(没有 kotlin 的项目在尝试同步时也会抛出此错误),因此这不是可行的选择。
有没有人知道它可能是什么?
我试图使用 Stetho 调试我的应用程序,并按照https://developers.google.com/web/tools/chrome-devtools/remote-debugging此处的步骤启用 chrome 远程调试,但我无法检查我的应用程序. 设备被识别,但没有检查链接:
我做了什么:
ADB
并运行adb devices
我可能会错过什么?
编辑:
我做了更多的测试,结果如下:
所以问题似乎是我在我的 APP 中做了或没有做的事情。
我正在使用 Spring 在 Kotlin 中制作简单的应用程序,但我在验证方面遇到了问题。
我有这个实体类:
@Entity
@Table(name = "category")
data class Category(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long?,
@field:NotNull @field:NotEmpty val name: String)
Run Code Online (Sandbox Code Playgroud)
我的控制器功能如下:
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
fun create(@Valid @RequestBody category: Category): ResponseEntity<Category>
Run Code Online (Sandbox Code Playgroud)
create
有一些代码,但与问题无关,我的问题是请求正文验证。如果我发送一个名称字段为空的类别,则会引发异常MethodArgumentNotValidException
,但如果我将 null 发送到该字段name
,则会引发异常HttpMessageNotReadableException
。有谁知道是否可以将 null 传递给标记为 的字段,@NotNull
也可以MethodArgumentNotValidException
在 Kotlin 中抛出。