Android编程 悬浮菜单按钮FloatingActionButton实例

分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

               

Android编程:悬浮菜单按钮FloatingActionButton实例


本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明.


环境:

主机:WIN10

开发环境:Android Studio 2.2 Preview 3


说明:

用第三方库FloatingActionButton实现悬浮菜单按钮


效果图:


布局:

"1.0" encoding="utf-8"?>"http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    xmlns:fab="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.bazhangkeji.classroom.session.VoiceSessionActivity">    "@+id/white_board"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:layout_alignParentStart="true"/>    "@+id/layout_avatar"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:paddingTop="8dp"        android:paddingLeft="16dp"        android:paddingRight="16dp">        "@+id/avatar"            android:layout_width="48dp"            android:layout_height="48dp"            android:src="@drawable/default_avatar"/>        "@+id/call_time"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_gravity="center"            android:layout_marginLeft="8dp"            android:layout_marginRight="8dp"            android:textColor="@color/black"            android:text="正在呼叫..."/>        "@+id/button_tool_menu"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentBottom="true"        android:layout_alignParentStart="true"        android:layout_margin="2dp"        fab:fab_addButtonColorNormal="@color/white_button"        fab:fab_addButtonColorPressed="@color/white_button_pressed"        fab:fab_addButtonPlusIconColor="@color/half_black"        fab:fab_addButtonSize="normal"        fab:fab_labelStyle="@style/menu_labels_style"        fab:fab_labelsPosition="right" >        "@+id/button_quit"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            fab:fab_colorNormal="@color/white_button"            fab:fab_colorPressed="@color/white_button_pressed"            fab:fab_icon="@drawable/ic_call_end_black_48dp"            fab:fab_size="mini"/>        "@+id/button_tool"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            fab:fab_colorNormal="@color/white_button"            fab:fab_colorPressed="@color/white_button_pressed"            fab:fab_icon="@drawable/ic_settings_applications_black_48dp"            fab:fab_size="mini"/>        "@+id/button_palette"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            fab:fab_colorNormal="@color/white_button"            fab:fab_colorPressed="@color/white_button_pressed"            fab:fab_icon="@drawable/ic_color_lens_black_48dp"            fab:fab_size="mini" />        "@+id/button_camera"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            fab:fab_colorNormal="@color/white_button"            fab:fab_colorPressed="@color/white_button_pressed"            fab:fab_icon="@drawable/ic_camera_alt_black_48dp"            fab:fab_size="mini" />    

源码:

        FloatingActionsMenu buttonToolMenu = (FloatingActionsMenu) findViewById(R.id.button_tool_menu);        FloatingActionButton buttonQuit = (FloatingActionButton) findViewById(R.id.button_quit);        FloatingActionButton buttonPalette = (FloatingActionButton) findViewById(R.id.button_palette);        FloatingActionButton buttonTool = (FloatingActionButton) findViewById(R.id.button_tool);        FloatingActionButton buttonCamera = (FloatingActionButton) findViewById(R.id.button_camera);        dialogClearScreenInit();        dialogPaletteInit();        dialogSelectImageInit();        progressDialogInit();        RxView.clicks(buttonQuit)                .throttleFirst(1, TimeUnit.SECONDS)                .compose(this.bindUntilEvent(ActivityEvent.DESTROY))                .subscribe(v -> {                    Voip.getInstance().hangUpCall(callId);                    finishActivity();                });        RxView.clicks(buttonPalette)                .throttleFirst(1, TimeUnit.SECONDS)                .compose(this.bindUntilEvent(ActivityEvent.DESTROY))                .subscribe(v -> {                    buttonToolMenu.collapse();                    dialogPalette.show();                });        RxView.clicks(buttonCamera)                .throttleFirst(1, TimeUnit.SECONDS)                .compose(this.bindUntilEvent(ActivityEvent.DESTROY))                .subscribe(v -> {                    buttonToolMenu.collapse();                    dialogSelectImage.show();                });


参考链接:

  1. futuresimple/android-floating-action-button


           

分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

你可能感兴趣的:(Android编程 悬浮菜单按钮FloatingActionButton实例)