Android Floating Action Button API 19 (KitKat)

前端 未结 2 1824
庸人自扰
庸人自扰 2020-12-15 05:08

I need to implement a floating action button, according to Google Design Guidelines, on my android application with API level 19.

However, I would know if some nativ

相关标签:
2条回答
  • 2020-12-15 05:51

    I would know if some native support library (like v4, v7, v13) to help me build this component without the need for external dependencies.

    No there aren't any support library floating action buttons (FAB). IMHO, it's a horrible decision to not include all of the material related widgets in the support library. In this video Chet Haase and Adam Powell basically say that the FAB is very easy to reproduce so they're not going to include it in any support library. So instead of Google creating one set of the material widgets to be used by millions of developers they would rather millions of developers create millions of different implementation of these widgets. </rant>

    You can just make your own FAB by extending the View class. Here is an example from Github of a FAB that does not use any outside libraries.

    0 讨论(0)
  • 2020-12-15 06:15

    Recently Google has released a new support library based on Material Design Guideline. The Codepath details the same components in this post.

    The library can be already used with Gradle adding the following line in build.gradle:

    dependencies {
        ...
        compile 'com.android.support:design:25.3.1'
    }
    

    This is a simple example of usage:

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

    See more FloatingActionButton example with Support Library.

    0 讨论(0)
提交回复
热议问题