浮动操作按钮以类似Skype的Arc样式显示

时间:2016-04-20 10:11:59

标签: java android android-studio floating-action-button

我正在自定义一个浮动操作按钮,它会展开以显示菜单,我已经实现了扩展菜单的FAB,但我想为它添加背景颜色,以及扩展菜单的背景颜色。

 ImageView imageView = new ImageView(this);
    imageView.setImageResource(R.drawable.notes_bottom_menu);  
    FloatingActionButton actionButton = new FloatingActionButton.Builder(this)
            .setContentView(imageView)
            .build();

    ImageView iconName = new ImageView(this);
    iconName.setImageResource(R.drawable.create_note);
    ImageView iconDate = new ImageView(this);
    iconDate.setImageResource(R.drawable.home_coach);
    ImageView iconRating = new ImageView(this);
    iconRating.setImageResource(R.drawable.bookmark);
    SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this);

    SubActionButton buttonName = itemBuilder.setContentView(iconName).build();
    SubActionButton buttonDate = itemBuilder.setContentView(iconDate).build();
    SubActionButton buttontRatings = itemBuilder.setContentView(iconRating).build();

    FloatingActionMenu actionMenu = new FloatingActionMenu.Builder(this)
            .addSubActionView(buttonName)
            .addSubActionView(buttonDate)
            .addSubActionView(buttonRatings)
            .attachTo(actionButton)
            .build();

这是我想要实施的示例图片

谢谢。

1 个答案:

答案 0 :(得分:2)

查看这个很棒的库https://github.com/saurabharora90/MaterialArcMenu

为build.gradle添加依赖项:

dependencies {
compile 'com.sa90.materialarcmenu:library:1.3'

}



<com.sa90.materialarcmenu.ArcMenu
    android:id="@+id/arcMenu"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    app:menu_scr="@drawable/ic_dialog_dialer"
    app:menu_open="arc_left">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab1"
        android:layout_width="wrap_content"
        android:src="@drawable/ic_dialog_email"
        android:layout_height="wrap_content" />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:src="@drawable/ic_dialog_alert"
        android:layout_height="wrap_content" />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:src="@drawable/ic_dialog_info"
        android:layout_height="wrap_content" />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:src="@drawable/ic_dialog_map"
        android:layout_height="wrap_content" />

</com.sa90.materialarcmenu.ArcMenu>