gpt4 book ai didi

android - 如何从 Android appcompat v7 21 库中设置 DrawerArrowToggle 的样式

转载 作者:IT老高 更新时间:2023-10-28 21:49:45 25 4
gpt4 key购买 nike

现在 Android 5.0 发布了,我想知道如何设置动画操作栏图标的样式。

这个图书馆here实现和样式对我来说很好,但是由于 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

<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>

但这样做时会崩溃并显示颜色类型错误。我错过了什么?

最佳答案

以下对我有用:

<style name="MyTheme" parent="Theme.AppCompat">
<item name="drawerArrowStyle">@style/MyDrawerArrowToggle</item>
</style>

<style name="MyDrawerArrowToggle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">@color/your_color</item>
</style>

关于android - 如何从 Android appcompat v7 21 库中设置 DrawerArrowToggle 的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26439572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com