现在Android 5.0已经发布,我想知道如何为动画操作栏图标设置样式。
这个库对于我来说实现和样式都很好,但既然appcompat v7库也有它,那么该如何设置样式呢?
我使用了v7 DrawerToggle进行了实现,但是我无法为其设置样式。请帮忙。
我在v7 styles_base.xml中找到了它的样式。
<style name="Base.Widget.AppCompat.DrawerArrowToggle" parent="">
<item name="color">?android:attr/textColorSecondary</item>
<item name="thickness">2dp</item>
<item name="barSize">18dp</item>
<item name="gapBetweenBars">3dp</item>
<item name="topBottomBarArrowSize">11.31dp</item>
<item name="middleBarArrowSize">16dp</item>
<item name="drawableSize">24dp</item>
<item name="spinBars">true</item>
</style>
我将这个添加到我的样式表中,但没有起作用。还将它添加到了我的attr.xml文件中。
我加入这个到我的样式但没效果。也加到我的attr.xml里了。
<declare-styleable name="DrawerArrowToggle">
<!-- The drawing color for the bars -->
<attr name="color" format="color"/>
<!-- Whether bars should rotate or not during transition -->
<attr name="spinBars" format="boolean"/>
<!-- The total size of the drawable -->
<attr name="drawableSize" format="dimension"/>
<!-- The max gap between the bars when they are parallel to each other -->
<attr name="gapBetweenBars" format="dimension"/>
<!-- The size of the top and bottom bars when they merge to the middle bar to form an arrow -->
<attr name="topBottomBarArrowSize" format="dimension"/>
<!-- The size of the middle bar when top and bottom bars merge into middle bar to form an arrow -->
<attr name="middleBarArrowSize" format="dimension"/>
<!-- The size of the bars when they are parallel to each other -->
<attr name="barSize" format="dimension"/>
<!-- The thickness (stroke size) for the bar paint -->
<attr name="thickness" format="dimension"/>
</declare-styleable>
但在执行此操作时,会崩溃并出现颜色类型错误。我缺少什么?
colorControlNormal
属性来同时更改两者。请参见我的答案https://dev59.com/8F8d5IYBdhLWcg3wxkpq#28450500 - marwinXXIIandroid:theme="@style/Toolbar_Theme"
?如果是的话,请尝试将其更改为app:theme="@style/Toolbar_Theme"
。 - Paul M.