Возможно, вы захотите применить пользовательский вид к панели действий. Попробуйте что-то вроде этого:
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
LayoutInflater inflator = (LayoutInflater) this .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflator.inflate(R.layout.action_bar_layout, null);
actionBar.setCustomView(view);
А вот action_bar_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_horizontal">
<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/YOUR_IMAGE_GOES_HERE" />
</RelativeLayout>
I'am получаю сообщение об ошибке на getSupportActionBar(); «Метод getSupportActionBar() не определен», поэтому я изменил его на getActionBar(); и он все еще не работает –
это сработало спасибо; D –