public void FAB() { // in Activity Context ImageView icon = new ImageView(this); // Create an icon icon.setImageResource(R.drawable.start); FloatingActionButton actionButton = new FloatingActionButton.Builder(this).setContentView(icon).build(); drawable = getResources().getDrawable(R.drawable.starty); // Create menu items: ImageView share = new ImageView(this); // Create an icon icon.setImageDrawable(drawable); ImageView dare = new ImageView(this); // Create an icon icon.setImageResource(R.drawable.starty); ImageView care = new ImageView(this); // Create an icon icon.setImageResource(R.drawable.starty); SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this); SubActionButton button1 = itemBuilder.setContentView(share).build(); SubActionButton button2 = itemBuilder.setContentView(dare).build(); SubActionButton button3 = itemBuilder.setContentView(care).build(); // Create the menu with the items: FloatingActionMenu actionMenu = new FloatingActionMenu.Builder(this) .addSubActionView(button1) .addSubActionView(button2) .addSubActionView(button3) // ... .attachTo(actionButton) .build(); }
private void Init_View() { dir = new File(PATH); if (!dir.exists()) { dir.mkdirs(); Log.e(PATH, dir.mkdirs() + ""); } final ImageView fabIconNew = new ImageView(this); fabIconNew.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_new_light)); rightLowerButton = new FloatingActionButton.Builder(this).setContentView(fabIconNew).build(); rLSubBuilder = new SubActionButton.Builder(this); ImageView rlIcon1 = new ImageView(this); ImageView rlIcon2 = new ImageView(this); ImageView rlIcon3 = new ImageView(this); ImageView rlIcon4 = new ImageView(this); ImageView rlIcon5 = new ImageView(this); ImageView rlIcon6 = new ImageView(this); rlIcon1.setImageDrawable(getResources().getDrawable(R.drawable.iconfont_color)); rlIcon2.setImageDrawable(getResources().getDrawable(R.drawable.iconfont_bi)); rlIcon3.setImageDrawable(getResources().getDrawable(R.drawable.iconfont_daoru)); rlIcon4.setImageDrawable(getResources().getDrawable(R.drawable.iconfont_xpc)); rlIcon5.setImageDrawable(getResources().getDrawable(R.drawable.iconfont_clear)); rlIcon6.setImageDrawable(getResources().getDrawable(R.drawable.icon_chonghui)); rightLowerMenu = new FloatingActionMenu.Builder(this) .addSubActionView(rLSubBuilder.setContentView(rlIcon6).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon1).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon2).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon3).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon4).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon5).build()) .attachTo(rightLowerButton) .build(); rightLowerMenu.setStateChangeListener( new FloatingActionMenu.MenuStateChangeListener() { @Override public void onMenuOpened(FloatingActionMenu menu) { // Rotate the icon of rightLowerButton 45 degrees clockwise fabIconNew.setRotation(0); OPEN = true; PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, 45); ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(fabIconNew, pvhR); animation.start(); } @Override public void onMenuClosed(FloatingActionMenu menu) { // Rotate the icon of rightLowerButton 45 degrees counter-clockwise fabIconNew.setRotation(45); OPEN = false; PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, 0); ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(fabIconNew, pvhR); animation.start(); } }); rlIcon3.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("file/*"); startActivityForResult(intent, SELECT_FILE); return true; } }); rlIcon6.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { if (!paintView.isShowing()) { paintView.preview(pathNode.getPathList()); } } }); rlIcon6.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { paintView.PathNodeToJson(pathNode, dir); return false; } }); rlIcon5.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (!paintView.isShowing()) { paintView.clean(); pathNode.ClearList(); paintView.clearReUnList(); } } }); rlIcon4.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { paintView.Eraser(); } }); rlIcon2.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { paintView.Paint(); } }); Init_Eraser_View(); rlIcon2.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Init_First_Dialog(); mMaterialDialog.show(); return true; } }); rlIcon1.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { ColorPickerDialogFragment f = ColorPickerDialogFragment.newInstance(DIALOG_ID, null, null, Color.BLACK, true); f.setStyle(DialogFragment.STYLE_NORMAL, R.style.LightPickerDialogTheme); f.show(getFragmentManager(), "d"); } }); rlIcon4.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Init_Eraser_View(); mMaterialDialog.show(); return true; } }); rlIcon3.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "选择图片"), SELECT_PICTURE); } }); rightLowerButton.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Log.e("", Environment.getExternalStorageDirectory().getPath() + "/DrawAPicture"); paintView.BitmapToPicture(dir); return true; } }); }
private void initCircularActionMenu(FloatingActionButton fab) { SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this); ImageView itemIcon1 = new ImageView(this); itemIcon1.setImageDrawable(getResources().getDrawable(R.drawable.ic_whatshot_white_48dp)); SubActionButton button1 = itemBuilder .setContentView(itemIcon1) .setBackgroundDrawable( getResources().getDrawable(R.drawable.navigation_button_background)) .build(); button1.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mActionMenu.close(true); onNavigationItemID(R.id.nav_guidance); mNavigationView.setCheckedItem(R.id.nav_guidance); } }); ImageView itemIcon2 = new ImageView(this); itemIcon2.setImageDrawable(getResources().getDrawable(R.drawable.ic_star_white_48dp)); SubActionButton button2 = itemBuilder .setContentView(itemIcon2) .setBackgroundDrawable( getResources().getDrawable(R.drawable.navigation_button_background)) .build(); button2.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mActionMenu.close(true); onNavigationItemID(R.id.nav_favorite); mNavigationView.setCheckedItem(R.id.nav_favorite); } }); ImageView itemIcon3 = new ImageView(this); itemIcon3.setImageDrawable( getResources().getDrawable(R.drawable.ic_format_list_bulleted_white_48dp)); SubActionButton button3 = itemBuilder .setContentView(itemIcon3) .setBackgroundDrawable( getResources().getDrawable(R.drawable.navigation_button_background)) .build(); button3.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mActionMenu.close(true); onNavigationItemID(R.id.nav_all_boards); mNavigationView.setCheckedItem(R.id.nav_all_boards); } }); ImageView itemIcon4 = new ImageView(this); itemIcon4.setImageDrawable(getResources().getDrawable(R.drawable.ic_email_white_48dp)); SubActionButton button4 = itemBuilder .setContentView(itemIcon4) .setBackgroundDrawable( getResources().getDrawable(R.drawable.navigation_button_background)) .build(); button4.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mActionMenu.close(true); onNavigationItemID(R.id.nav_mail); mNavigationView.setCheckedItem(R.id.nav_mail); } }); mActionMenu = new FloatingActionMenu.Builder(this) .addSubActionView(button1) .addSubActionView(button2) .addSubActionView(button3) .addSubActionView(button4) .attachTo(fab) .build(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); ImageLoader imageLoader = ImageLoader.getInstance(); imageLoader.init(ImageLoaderConfiguration.createDefault(this)); setTitle("Fashion House b-Home"); myGridView = (StaggeredGridView) findViewById(R.id.grid_view); homeAdapter = new HomeAdapter(this, android.R.layout.simple_list_item_1, generateData()); if (savedInstanceState != null) { myData = savedInstanceState.getStringArrayList(SAVED_DATA_KEY); } if (myData == null) { myData = generateData(); } for (String data : myData) { homeAdapter.add(data); } myGridView.setAdapter(homeAdapter); myGridView.setOnScrollListener(this); myGridView.setOnItemClickListener(this); // creating the circular button final com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton mymenu = new com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.Builder(this) .build(); SubActionButton.Builder rLSubBuilder = new SubActionButton.Builder(this); // Setting icons to the buttons ImageView rlIcon1 = new ImageView(this); ImageView rlIcon2 = new ImageView(this); ImageView rlIcon3 = new ImageView(this); ImageView rlIcon4 = new ImageView(this); ImageView rlIcon5 = new ImageView(this); ImageView rlIcon6 = new ImageView(this); // setting icons for the buttons rlIcon1.setImageDrawable(getResources().getDrawable(R.drawable.help)); rlIcon2.setImageDrawable(getResources().getDrawable(R.drawable.business)); rlIcon3.setImageDrawable(getResources().getDrawable(R.drawable.cartfull)); rlIcon4.setImageDrawable(getResources().getDrawable(R.drawable.car)); rlIcon5.setImageDrawable(getResources().getDrawable(R.drawable.car)); rlIcon6.setImageDrawable(getResources().getDrawable(R.drawable.car)); // creating the floating action menu subButtos being created dynamically final FloatingActionMenu myFloatingMenu = new FloatingActionMenu.Builder(this) .addSubActionView(rLSubBuilder.setContentView(rlIcon1).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon2).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon3).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon4).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon5).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon6).build()) .attachTo(mymenu) .build(); rlIcon1.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Home.this, help.class); startActivity(i); } }); rlIcon2.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i2 = new Intent(Home.this, Contact.class); startActivity(i2); } }); rlIcon3.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i3 = new Intent(Home.this, Checkout.class); startActivity(i3); } }); rlIcon4.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i4 = new Intent(Home.this, MakeUp.class); startActivity(i4); } }); rlIcon5.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i5 = new Intent(Home.this, Category.class); startActivity(i5); } }); rlIcon6.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i5 = new Intent(Home.this, SignUp.class); startActivity(i5); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.app_bar); mTabs = (SlidingTabLayout) findViewById(R.id.tabs); mPager = (ViewPager) findViewById(R.id.pager); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowHomeEnabled(true); NavigationDrawerFragment drawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); drawerFragment.setUp((DrawerLayout) findViewById(R.id.drawer_layout), toolbar); mPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager())); mTabs.setDistributeEvenly(true); mTabs.setViewPager(mPager); ImageView imageView = new ImageView(this); imageView.setImageResource(R.drawable.plus); FloatingActionButton actionButton = new FloatingActionButton.Builder(this) .setContentView(imageView) .setBackgroundDrawable(R.drawable.button_action_red) .build(); ImageView videoIcon = new ImageView(this); videoIcon.setImageResource(R.drawable.video); ImageView galleryIcon = new ImageView(this); galleryIcon.setImageResource(R.drawable.gallery); ImageView audioIcon = new ImageView(this); audioIcon.setImageResource(R.drawable.audio); SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this); SubActionButton buttonVideo = itemBuilder.setContentView(videoIcon).build(); SubActionButton buttonGallery = itemBuilder.setContentView(galleryIcon).build(); SubActionButton buttonAudio = itemBuilder.setContentView(audioIcon).build(); FloatingActionMenu actionMenu = new FloatingActionMenu.Builder(this) .addSubActionView(buttonVideo) .addSubActionView(buttonGallery) .addSubActionView(buttonAudio) .attachTo(actionButton) .build(); buttonGallery.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "select picture"), 1); Toast.makeText(Login.this, "Done....", Toast.LENGTH_SHORT).show(); } }); buttonVideo.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getApplicationContext(), VideoPlay.class)); } }); }