如何在Android Material Design中为浮动操作按钮创建子菜单?

时间:2015-10-09 09:48:57

标签: android material-design submenu floating-action-button

点击我的浮动操作按钮后,我想创建一个子菜单

SubMenu Fab

我已经知道这个图书馆:

  

https://github.com/futuresimple/android-floating-action-button

但是我想用原创FAB android支持设计来创建它:

compile 'com.android.support:design:23.+'

<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_add" />

1 个答案:

答案 0 :(得分:9)

不可能直接。 ImageViewLinearLayout的子类,不能托管子代。您必须实现自己的ViewGroup(垂直FloatingActionButton应该足够)并将radiolauncherswitch = (Switch) findViewById(R.id.radiolauncherswitch); if(!read("radyolauncher")) radiolauncherswitch.setChecked(false); else radiolauncherswitch.setChecked(true); radiolauncherswitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { save("radyolauncher",true); Intent launcher = new Intent(Settings.this,Radyo.class); launcher.addCategory("CATEGORY_LAUNCHER"); } else { save("radyolauncher",false); Intent launcher = new Intent(Settings.this,Radyo.class); launcher.removeCategory("CATEGORY_LAUNCHER"); } } }); 放入其中

相关问题