2015-06-23 48 views
-1

我有一个自定义操作栏。我使用buttonTextView创建了操作栏布局。我想,当用户按回按钮时,改变后退按钮的视图。像用户点击后退按钮的gmail应用程序,矩形显示在后退按钮上,但我希望显示后退按钮的圆圈。我想链接图片,但我没有允许。在操作栏上显示后退按钮

我不知道如何计算任何尺寸的设备的圆的半径。 感谢您的建议,并对我的英文不好。

+0

请给我任何的屏幕截图,所以我得到任何想法也 –

+0

感谢您的快速回复。 http://tinypic.com/r/25aoily/8这个网址显示我的意思 – TestAndroid

+0

这将帮助你http://stackoverflow.com/questions/9252354/how-to-customize-the-back-button-on-actionbar –

回答

1

最简单的方法是做两个不同的图标,一个带有圆圈,另一个没有它。那么你将不会有任何问题的设备的大小。

你可以用这样的选择做到这一点:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item android:state_pressed="true" android:drawable="@drawable/your_icon_with_circle"/> 
    <item android:drawable="@drawable/your_icon_without_circle" /> 
</selector> 

然后你就可以选择设置到按钮背景