Material 对每一项的编辑按钮的设计建议

Material Design suggestions for edit button for each item

我想为项目列表中的每个按钮添加一个编辑按钮。 Android 每个视图只能使用一次操作按钮,这样就没有意义了。有没有其他方法可以遵循 material 指南?这个按钮应该是根据整个编辑按钮是否被按下而飞走和飞起的东西。

您可能应该使用 flat or raised button(取决于您的编辑功能的重要性)。

您应该使用平面按钮,因为按钮会从背景中弹出,很容易吸引注意力并引导用户的视线。 Here 关于这个

很好 post

更新:

要设计平面按钮效果,您必须执行以下操作

  1. 定义您的按钮并将背景设置为包含按下状态和默认状态定义的可绘制对象
  2. 为按下状态写一个纯色的可绘制资源
  3. 对于默认状态,编写一个可绘制对象,其中包含一个指向已按下状态可绘制对象的项目作为背景。并用 android:bottom="2dp"
  4. 绘制一个较浅的形状作为另一个项目

flat_button.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="true" android:drawable="@drawable/rect_pressed"/>
  <item android:drawable="@drawable/rect_normal"/>
</selector>

rect_normal.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:drawable="@drawable/rect_pressed" />

  <item android:bottom="@dimen/layer_padding">
      <shape android:shape="rectangle">
          <corners android:radius="@dimen/corner_radius" />
          <solid android:color="@color/blue_normal" />
      </shape>
  </item>
</layer-list>

rect_pressed.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <corners android:radius="@dimen/corner_radius" />
  <solid android:color="@color/blue_pressed" />
</shape>

如果您需要阅读完整教程go here