I am using ToolBar in my project first time, so i do not know how to customized the toolbar in android. I need to centered title in to the tool bar and how to do that please
This did my work!
Toolbar toolbar = findViewById(R.id.mytoolbar);
TextView titleText = getProperties(new TextView(this));
FrameLayout frameLayout = new FrameLayout(this);
frameLayout.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
frameLayout.addView(titleText);
toolbar.addView(frameLayout);
setSupportActionBar(toolbar);
Method to Set TextView Properties
private TextView getProperties(TextView titleText){
titleText.setText(wallpaperName);
titleText.setTextColor(Color.WHITE);
titleText.setTextSize(18f);
titleText.setShadowLayer(2f,2f,2f,Color.BLACK);
titleText.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); // CENTER ALIGNMENT
return titleText;
}