[英]How to create a submenu for Floating Action Button in Android Material Design?
[英]Is there a native component for the Floating action button in Android Material Design?
我的問題圍繞Android Material Design中引入的浮動操作按鈕 。
有很多庫在GitHub上提供這個組件:
但我的問題是:
是否有一個本機組件與android.support.vX
的最后一個版本是為Floating action button
構建的?
組件如:
今天(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.