I have a toolbar in my activity (actionbar app is removed). In my toolbar, I have a title and icon. Now I want to move the title to the right with this code: android:layoutDirection="rtl" but the icon is also moved.
I want to move only the title to the right.
Toolbar code:
<style name="ToolBar" parent="AppTheme">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColorSecondary">@color/colorToolbar</item>
<item name="titleTextColor">@color/colorToolbar</item>
<item name="android:background">?attr/colorPrimary</item>
<item name="android:layoutDirection">rtl</item>
</style>
Activity.java :
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_addNewItem);
setSupportActionBar(toolbar);
if(getSupportActionBar() != null){
getSupportActionBar().setTitle("کلاس جدید");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

You have to make TextView inside toolbar and set gravity as you want. for your problem it is not necessary to take toolbar, you can also use layout. This is my coordinate layout. In which you can easily adjust TextView inside toolbar.