【问题标题】:Cut, copy and paste from long press menu look like Material buttons从长按菜单剪切、复制和粘贴看起来像 Material 按钮
【发布时间】:2018-06-26 14:14:30
【问题描述】:

到目前为止,我一直在尝试使用新的材质库,并注意到 TextInputEditText 的长按菜单将剪切、复制、粘贴和其他选项显示为菜单中的材质按钮。我没有做任何自定义代码,长按菜单是系统默认的。发生了什么事?

我已经实现了 'com.google.android.material:material:1.0.0-alpha3' 并且所有库都是 androidx。在 SDK23 上测试。

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<data>
    <variable
        name="viewmodel"
        type="io.jayasurya.ruby.MainViewModel"/>

</data>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center"
    tools:context=".AddFragment">

    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="12dp"
            android:hint="Name"
            android:text="@={viewmodel.name}"
            android:id="@+id/nameInput" />
    </com.google.android.material.textfield.TextInputLayout>

    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000"
        android:id="@+id/btn"
        android:text="@{viewmodel.name}" />

</LinearLayout>
</layout>

样式

<resources>

<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>

</resources>

【问题讨论】:

  • 看起来您已将样式应用于默认按钮类。指定您自己的样式,然后在“确定”按钮上引用该样式。添加您的样式/主题和布局代码以获得更好的答案。
  • 欢迎来到 Stack Overflow。请花点时间阅读How to Ask,了解一些改进问题的技巧。
  • @CodeChimp 长按菜单项也算作应用程序可以影响的按钮吗?
  • 看起来材质库确实会受到您的 colorAccent 的影响。尝试使用标准的 EditText 并查看它是否表现出相同的行为。可能是错误/功能。
  • 更新这发生在我在 Marshmallow 6.0 上运行的旧设备上,我在带有 android P 的模拟器上运行它,它工作得很好,通常的长按菜单。那么它是旧设备的材料库中的一个错误吗?感谢人们,您的想法。

标签: android material-design


【解决方案1】:

这是由material design view inflater和Google has fixed it引起的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-28
    • 2012-01-08
    • 2019-06-01
    • 2010-11-17
    • 1970-01-01
    • 1970-01-01
    • 2011-02-25
    相关资源
    最近更新 更多