【问题标题】:Button in android ignore background drawable resourcesandroid中的按钮忽略背景可绘制资源
【发布时间】:2019-06-20 11:03:59
【问题描述】:

所以,我正在开发一个 android 应用程序,并且在我迄今为止创建的所有布局中,我都有按钮,而不是 AppCompatButton 或 Material Button 只是简单的按钮,它具有以下属性集:

<Button
    android:id="@+id/logout"
    android:layout_margin="8dp"
    android:text="@string/log_out_button"
    android:textColor="#000"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/rounded_buttons"
    app:layout_constraintBottom_toBottomOf="parent"/>

rounded_buttons.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFF"/>
<corners
    android:radius="8dp"/>
</shape>

这会引发保真度警告: 不支持 Paint.letterspacing()。

奇怪的部分是这个 xml 在早期创建的布局中引用时按预期工作。 感谢您提供的任何帮助。

如果在我安装了第三方插件来导入素材图标后开始这样做有帮助:

Material Icon Generator

我已经禁用了这个插件,使缓存无效并重新启动了ide,在某处,它建议更改主题,尝试无济于事,所以将其改回我正在使用的那个。

【问题讨论】:

    标签: android android-layout android-drawable android-button


    【解决方案1】:

    这很尴尬,我所要做的就是将预览中的主题从 Material Components 到 AppTheme。

    没有早点想到这一点真是太愚蠢了。 Material Icon generator 也非常棒,不会导致这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2020-06-19
      • 1970-01-01
      • 2019-12-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多