我想用一个选择自定义我的动作栏项目的背景下,以覆盖显示什么时候按钮pssed $ P $。
这是pretty的易于使用的菜单键(例如,溢图标),你可以用 actionBarItemBackground
他们的风格。
I'm trying to customize the background of my action bar items with a selector, to override what is shown when the button is pressed.
This was pretty easy with menu buttons (e.g., overflow icon), as you can style them with actionBarItemBackground
.
可悲的是,这并不适用于向上/家庭/左指标。我已经试过失败,在我的styles.xml:
Sadly this does not apply for the up/home/left indicator. I have unsuccessfully tried, in my styles.xml:
<项目名称=actionButtonStyle>
;
<项目名称=actionBarStyle>
;
<项目名称=toolbarStyle>
;
没有的嵌套属性似乎作用于首页图标的背景。我还搜查了android.R.attr,给了一看这个。有什么办法?
None of the nested attributes seem to act on the home icon background. I also searched over android.R.attr and gave a look at this. Is there any way?
我想留在向上的指标,没有膨胀的自定义视图。在这种情况下,我也有夸大的标题以及自定义视图自然地出现在标题末尾。我会失去汉堡到箭头动画,我会好好关心利润和设计指南(现在 AppCompat
管理),以及其他一些不好的事情上的方式。
I would like to stay with the "up" indicator, without inflating a custom view. In that case, I would also have to inflate the title as well as custom views naturally appear at the end of the title. AND I would lose the burger-to-arrow animation, AND I would have to take care about margins and design guidelines (now managed by AppCompat
), and some other bad thing on the way.
我想过设置标志
,但会有一定的并发症,以及,我不认为我可以无论如何改变背景。
I thought about setting a Logo
, but that would have some complications as well and I don't think I could change the background anyway.
我想到了工具栏
是一个布局
,所以我可以从XML把自定义视图在里面。如果我没有错,他们的标题后出现,所以这也不是一个好主意。
I thought about Toolbar
being a Layout
, so I could put custom views in it from XML. If I'm not wrong they appear after the title, so neither this is a good idea.
我该怎么办?
请让我知道,如果作品 - 添加到您的主题,或者如果它不采取既除去一个与Android preFIX
please let me know if it works add this to your your theme or if it doesn't take both remove the one with android prefix
<item name="android:selectableItemBackground">@drawable/selector</item>
<item name="selectableItemBackground">@drawable/selector</item>
例@绘制/选择器:
Example @drawable/selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="#ddffffff" />
<item
android:drawable="@android:color/transparent" />
</selector>