package com.cpacm.demo.circularfloatingactionmenu_demo; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.ImageView; import com.cpacm.library.FloatingActionButton; import com.cpacm.library.FloatingActionMenu; import com.cpacm.library.SubActionButton; /** * Created by cpacm on 2014/11/24. */ public class MyFABActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_menu_with_fab); // Set up the white button on the lower right corner // more or less with default parameter ImageView fabIconNew = new ImageView(this); fabIconNew.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_new_light)); FloatingActionButton rightLowerButton = new FloatingActionButton.Builder(this) .setContentView(fabIconNew) .build(); SubActionButton.Builder 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); rlIcon1.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_chat_light)); rlIcon2.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_camera_light)); rlIcon3.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_video_light)); rlIcon4.setImageDrawable(getResources().getDrawable(R.drawable.ic_action_place_light)); // Build the menu with default options: light theme, 90 degrees, 72dp radius. // Set 4 default SubActionButtons FloatingActionMenu rightLowerMenu = new FloatingActionMenu.Builder(this) .addSubActionView(rLSubBuilder.setContentView(rlIcon1).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon2).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon3).build()) .addSubActionView(rLSubBuilder.setContentView(rlIcon4).build()) .setAnimationHandler(new SliderAnimationHandler()) .attachTo(rightLowerButton) .build(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_with_fab, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }