/ /スワイプタブの上に画像を追加するには? - java、android、eclipse、android-actionbar

スワイプタブの上に画像を追加するにはどうすればよいですか? - java、android、eclipse、android-actionbar

私は 画像 の上 スワイプタブ 下の画像のように

!

私はこれを追加してみました:

    getActionBar().setIcon(R.drawable.ic_launcher);

それを私のviewpager xmlのviewpagerの上に追加してもうまくいきませんでした

それを行う方法がありますか?

回答:

回答№1は1

カスタムビューをアクションバーに適用したい場合があります。このようなことを試してください:

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>