0

下面的代碼導致返回箭頭出現在動作條:ActionBar中可繪製的後退箭頭的標識是什麼?

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

我在尋找的箭頭可繪製的資源ID,即android.R.drawable.xxx。我需要這個ID的原因是我可以在我的應用程序的其他地方手動設置一個相同的箭頭(大小爲&顏色)。

我試着製作我自己的drawable並使用它,但尺寸與ActionBar中的不同。

回答

-2
R.id.home 

是在動作條 返回按鈕的id你可以得到它在onOptionItemSelected()方法,改變其行爲

-2

ActionBar中的後退箭頭繪製的ID是android.R.id.home

0

如果你有您項目中的支持​​庫,您可以在您的應用程序的任何位置製作後退按鈕,如下所示:

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

特別是後退箭頭的資源是?attr/homeAsUpIndicator