نقل قول: کاستومایز کردن اکشن بار
باید از یه layout خاص که طراحی کردید براش استفاده کنید مثل متد زیر
private void setupActionBar() { ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
LayoutParams lp1 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
View customNav = LayoutInflater.from(this).inflate(R.layout.actionb ar, null); // layout which contains your button.
actionBar.setCustomView(customNav, lp1); }
و اینم فایل layou
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_horizontal"
android:orientation="horizontal"
android:background="@color/Blue">
<TextView
android:id="@+id/text_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_menu"
android:textColor="@color/White"
android:paddingLeft="5dp"
android:layout_gravity="left"/>
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/Icon"
android:layout_gravity="center"/>
<TextView
android:id="@+id/text_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_help"
android:layout_gravity="right"
android:textColor="@color/White"
android:paddingRight="5dp"/>
</LinearLayout>
نقل قول: کاستومایز کردن اکشن بار
اکشن بار منسوخ شده از تولبار استفاده کنید