简体   繁体   中英

How to add Floating Action button with appcompact

i recently updated by android sdk to new android 5.0
and was trying to add Floating action button (FAB) using appcompact..

i dont want to use any type of external libraries

How can i add FAB button to by project with appcompact

You don't need any special libraries to make a FAB. Make a class that extends ImageButton and in the onTouch method, scale your view up and down.

android now has the floating action button on their design:

just add compile 'com.android.support:design:22.2.0' on your gradle file and add

 <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="68dp"
        android:layout_marginRight="10dp"
        android:clickable="true"
        android:background="@mipmap/icon_plus_button"
        app:layout_anchor="@id/mainContent"
        app:layout_anchorGravity="bottom|right|end"
        app:fabSize="mini"
        app:backgroundTint="#5894EF"
        app:elevation="6dp"
        app:rippleColor="@android:color/transparent"
        app:pressedTranslationZ="12dp"/>

on your xml layout. Hope this helps anyone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM