-1
在我的布局中,我在顶部没有工具栏的图像视图。我想要在我的imageview上有工具栏的后退箭头按钮,例如在imageview上带有后退箭头的whatsapp配置文件视图。如何添加工具栏上的后退箭头按钮到图像视图
我加入这个
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
在我的布局中,我在顶部没有工具栏的图像视图。我想要在我的imageview上有工具栏的后退箭头按钮,例如在imageview上带有后退箭头的whatsapp配置文件视图。如何添加工具栏上的后退箭头按钮到图像视图
我加入这个
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
编辑您的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>
它会是这样的。
而且,你会从here获得的图标。
非常感谢你的回答 –
你可以接受我的回答并投票赞成。 :) –