如何从 Android appcompat v7 21 库中设置 DrawerArrowToggle 的样式 [英] How to style the DrawerArrowToggle from Android appcompat v7 21 library

查看:24
本文介绍了如何从 Android appcompat v7 21 库中设置 DrawerArrowToggle 的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

So now that Android 5.0 was released i was wondering how to style the animated actionbar icons.

这个库这里 实现和样式对我来说很好,但是因为 appcompat v7 库有它如何设计?

This library here implements and styles it fine for me but since the appcompat v7 library has it how can it be styled?

我使用 v7 DrawerToggle 实现了这一点.但是我不能设计它.请帮忙

I got this implemented using the v7 DrawerToggle. However I cannot style it. Please Help

我在 v7 styles_base.xml 中找到了它的样式

I found the styling for it in the 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

I added this to my styles and did not work. Also added to my 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>

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

But crashes and says color type error when doing so. What am i missing?

推荐答案

以下对我有用:

<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 appcompat v7 21 库中设置 DrawerArrowToggle 的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆