簡體   English   中英

Android Material Design中的浮動操作按鈕是否有本機組件?

[英]Is there a native component for the Floating action button in Android Material Design?

我的問題圍繞Android Material Design中引入的浮動操作按鈕

在此輸入圖像描述

有很多庫在GitHub上提供這個組件:

  1. Android的浮動動作按鈕
  2. FloatingActionButton
  3. CircularFloatingActionMenu
  4. FAB
  5. 浮動作按鈕

但我的問題是:

是否有一個本機組件與android.support.vX的最后一個版本是為Floating action button構建的?

組件如:

  • android.support.v7.cardview
  • android.support.v4.widget.DrawerLayout
  • android.support.v7.widget.RecyclerView
  • ...

今天(2015年5月29日)它正式推出新的Material Design支持庫。

只需將此依賴項添加到build.gradle

compile 'com.android.support:design:22.2.0'

將此視圖添加到您的布局:

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:src="@drawable/ic_done" />

並使用它:

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        //TODO
    }
});

還沒有,有跡象表明我們會在下一個支持庫中看到它。

您可以在md按鈕上使用md-fab類,然后在md按鈕內添加帶有加號的跨度。 還有其他md-fab類,如md-fab-bottom-right,可能會幫助你。 您也可以在md按鈕內使用md-icon

<md-button class="md-fab"><span class="glyphicon glyphicon-plus" /></md-button>

以上所有答案現已過時。

FABS作為Android的Material Components的一部分提供: https//material.io/develop/android/docs/getting-started/

這是課程: https//developer.android.com/reference/com/google/android/material/floatingactionbutton/FloatingActionButton

不要錯過目錄應用程序的工作示例: https//github.com/material-components/material-components-android

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM