I'm trying to add a button in the top right corner of a toolbar, this is my code:
mToolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
verified_btn = new Button(getActivity());
verified_btn.setBackgroundResource(R.drawable.ic_done_black_24dp);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT, Toolbar.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_END);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.width = 80;
params.height = 80;
verified_btn.setLayoutParams(params);
verified_btn.setOnClickListener(this);
mToolbar.addView(verified_btn);
but this is the result:
I have tried different way, but is always there, how I can do?