点击我的浮动操作按钮后,我想创建一个子菜单:
我已经知道这个图书馆:
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" />
答案 0 :(得分:9)
不可能直接。 ImageView
是LinearLayout
的子类,不能托管子代。您必须实现自己的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");
}
}
});
放入其中