在ActionBar中可绘制的后退箭头的ID是什么? [英] What is the ID of the back arrow drawable in the ActionBar?

查看:161
本文介绍了在ActionBar中可绘制的后退箭头的ID是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码使向后箭头出现在ActionBar中:

The following code causes a back arrow to appear in the ActionBar:

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

我正在寻找可绘制箭头的资源ID,即android.R.drawable.xxx.我需要此ID的原因是为了可以在应用程序的其他位置手动设置相同的箭头(大小和颜色).

I'm looking for the resource ID of the arrow drawable, i.e. android.R.drawable.xxx. The reason I need this ID is so that I can manually set an identical arrow (size & colour) elsewhere in my app.

我尝试制作自己的drawable并使用它,但是大小与ActionBar中的大小不同.

I tried making my own drawable and using that but the size was different from the one in the ActionBar.

推荐答案

如果您的项目中有支持库,则可以在应用程序中的任何位置创建后退按钮,如下所示:

If you have the support library in your project, you can make a back button in any place in your applicaction like this:

<ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="?attr/homeAsUpIndicator"
        android:background="?attr/selectableItemBackgroundBorderless"/>

具体来说,后退箭头的资源是?attr/homeAsUpIndicator.

Specifically the resource for the back arrow is ?attr/homeAsUpIndicator.

这篇关于在ActionBar中可绘制的后退箭头的ID是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆