I have a mobile project using android studio. I wonder how to make my logo centeren in action bar. after I put an item in action bar, the logo is not centered.
and here is my custom action bar view
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_actionbar_relative_layout_main"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="vertical"
android:background="@color/transparent"
android:enabled="false">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="5dp"
android:padding="10dp"
android:src="@drawable/ic_logo"
android:contentDescription="@string/logo" />
</LinearLayout>
I put my item programaticaly in activity class
supportActionBar?.apply {
displayOptions = ActionBar.DISPLAY_SHOW_CUSTOM
setDisplayShowCustomEnabled(true)
setCustomView(R.layout.custom_action_bar)
elevation = 3f
}