【问题标题】:Android Home As Up Indicator filename or locationAndroid Home As Up 指示器文件名或位置
【发布时间】:2014-05-14 22:44:51
【问题描述】:

我在哪里可以找到可绘制的 Android“向上”按钮,以便我可以自定义它?或者它的文件名是什么,以便我可以快速搜索以在 sdk 目录中找到它?

【问题讨论】:

    标签: android android-resources android-drawable android-assets


    【解决方案1】:

    正如您在default style(最后)中看到的,ActionBar 样式使用了这个:

    <style name="Widget.Holo.Light.ActionBar" parent="Widget.Holo.ActionBar">
        <item name="android:homeAsUpIndicator">@android:drawable/ic_ab_back_holo_light</item>
    </style>
    

    您可以找到layout resource 用于在您的 ActionBar 上显示 UpApp 图标。 这些元素(UpApp 图标)的位置是硬编码到布局资源中的,可能很难更改或自定义它。但是,您没有没有太多解释,所以我会尝试回答可能的自定义。

    您可以按照自己的风格自定义向上指示器,并按如下方式放置自己的图标:

    <style name="Theme" parent="@style/Theme.Holo.Light">
        <item name="android:homeAsUpIndicator">@drawable/ic_up_indicator</item>
    </style>  
    

    注意:必须是父样式,不能是ActionBar的样式。

    那么,如果你想调整 Upicon 之间的内边距,你有以下解决方案:

    1. 创建一个自定义视图并隐藏内置的主页导航 (see an example)。
    2. setPadding dynamically 更改它(但是,这必须在每个活动上都使用,而且有点乱)。
    3. 使用可绘制图层列表并替换 homeAsUpIndicator 主题 (described here)。

    最后,您可以在Android Drawable's website/res/drawable-xxx 上获得这个图标,命名为ic_ab_back_holo_light_am.pngic_ab_back_holo_dark_am.png

    更新:
    从 MaterialDesign 开始,您可以在 Material Design Icons 上找到这个名为“arrow-left”的图标。

    我希望这会有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多