Skip to content

Instantly share code, notes, and snippets.

@pavi2410
Created November 29, 2017 12:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavi2410/5bf27bb73b87ae8edb47833aa2a0f0a6 to your computer and use it in GitHub Desktop.
Save pavi2410/5bf27bb73b87ae8edb47833aa2a0f0a6 to your computer and use it in GitHub Desktop.
using official android fab lib
FloatingActionButton fab = new FloatingActionButton(context);
fab.setId(View.generateViewId());
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("DEBUG", "onFabFoo");
}});
fab.setImageResource(R.drawable.btn_plus);
fab.setElevation(2);
fab.setSize(FloatingActionButton.SIZE_MINI);
fab.setFocusable(true);
RelativeLayout.LayoutParams lay = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lay.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lay.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
lay.setMargins(2,2,2,2);
fab.setLayoutParams(lay);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment