private void setToolBarCenterTitle() {
TextView titleTv = new TextView(this);
titleTv.setTextColor(ContextCompat.getColor(this, R.color.black));
titleTv.setText("Title居中显示");
titleTv.setTextSize(20);
titleTv.setGravity(Gravity.CENTER);
titleTv.getPaint().setFakeBoldText(true);
Toolbar.LayoutParams layoutParams = new Toolbar.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT,
Toolbar.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.CENTER;
titleTv.setLayoutParams(layoutParams);
Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.addView(titleTv);
}