2016-04-13 27 views
-1

私のレイアウトでは、ツールバーなしで画像ビューが表示されます。私はイメージビューに戻る矢印のあるwhatsappプロファイルビューのように、私のイメージビューにツールバーの戻る矢印ボタンを持っています。 ツールバーの戻るボタンを画像ビューに追加する方法

は、私は、次の画像を使用しドロウアブルするためにそれを保存し、この

getSupportActionBar().setDisplayHomeAsUpEnabled(true); 

答えて

0

を追加することで、結果を得た。この結果enter image description here

を望んでいました。

enter image description here

し、次のコード

<ImageView 
      android:id="@+id/back_arrow" 
      android:layout_width="25dp" 
      android:layout_height="25dp" 
      android:src="@drawable/ic_arrow_back" /> 
1

編集このようなあなたのToolbarで使用。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" 
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" > 

    <ImageView 
     android:id="@+id/back_button" 
     android:layout_width="25dp" 
     android:layout_height="25dp" 
     android:src="@drawable/ic_back_button" /> 

</android.support.v7.widget.Toolbar> 

このようになります。

enter image description here

また、あなたはhereからアイコンを取得します。

+0

回答ありがとうございました –

+0

あなたは私の答えを受け入れ、アップの投票をすることができます。 :) –

関連する問題