动作条返回/主页Arrow填充和pressed州动作、主页、pressed、Arrow

2023-09-12 03:27:49 作者:永远别放弃

我想有在我的活动动作条为向上导航为用户提供选项/家庭箭头按钮。在我的活动,我已经设置设置 getActionBar()setDisplayHomeAsUpEnabled(真); ,也定义了 parentActiviy 清单中像这样的:

I wanted to have up/home arrow button in my activity ActionBar to provide users option for navigating up. In my activity, I have set set getActionBar().setDisplayHomeAsUpEnabled(true); and also have defined parentActiviy in Manifest like this:

<activity
        android:name="com.g_node.gca.map.MapActivity"
        android:parentActivityName="com.g_node.gca.MainActivity"
        android:label="@string/title_activity_map" >
</activity>

它的工作原理,我看到左箭头图标在动作条的图标之前,即采取的onClick回parentActivity。但我看不到的动作条标题或图标状态发生任何变化,当它被点击/ pressed。

It works and I see a left-arrow icon before the icon in ActionBar, that onClick takes back to parentActivity. But I don't see any change in state of actionbar title or icon, when it's clicked/pressed.

哪有我的风格,所以当用户点击该图标,它显示了一个 pressed 状态?就像下面的截图:

How can I style that so when user clicks on that icon, it shows a pressed state? Like in following screenshot:

此外,如何设置左箭头图标和动作条图标之间的填充在我的活动动作条,两者几乎贴,请参阅下面的参考截图:

Moreover, How can I set the padding between the left-arrow icon and the actionbar icon ? In my activity actionbar, both are almost sticked, see screenshot below for reference:

还有一件事 - 我用务实 getActionBar()设置此图标在我的setIcon活动(getResources()getDrawable(R.drawable.icon_maps)); 和图标大小为128×128。

One more thing - I'm setting this icon in my activity pragmatically using getActionBar().setIcon(getResources().getDrawable(R.drawable.icon_maps)); and icon size is 128 x 128.

三江源提前寻求帮助。

推荐答案

您可以通过设置actionBarItemBackground属性在你的主题改变的背景。这应该是一个国家的列表绘制反映国家,如pressed,重点突出。

You can change the background by setting the actionBarItemBackground attribute in your theme. This should be a state-list drawable which reflects states such as pressed and focused.

@android:彩色/透明

@android:color/transparent