【问题标题】:ActionBar not scaling onto ActionBar heightActionBar 未缩放到 ActionBar 高度
【发布时间】:2012-05-17 21:15:27
【问题描述】:

我有一个问题我不明白:

我刚刚在我的应用程序上设置了一个 ActionBar(目标 SDK 11,主题 Holo.Light)。但是当我以 XML 或 setBackgroundDrawable(d) 方式设置背景时, 背景没有缩放到 ActionBar 的高度:

-如果drawable太小,它会被拉伸以填充action bar的高度。 - 但如果太高,它不会缩回去,会覆盖在布局的其余部分上。

我刚刚遵循了 android dev 中提供的指南,并尝试通过 DrawableBitmap 进行设置,但结果相同。

非常感谢您的任何回答。

<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <!-- other activity and action bar styles here -->
</style>

<!-- style for the action bar backgrounds -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/ab_background</item>
</style>

【问题讨论】:

    标签: android background-image android-actionbar


    【解决方案1】:

    重复我理解你的意思:

    • 如果图像“小”,则将其拉伸以填充 ActionBar - 这是必需的行为,对吧?
    • 如果图像“大于小于”,则它与 ActionBar 区域重叠 - 这不是必需的行为,对吧?

    您设置为背景的 Drawable 是什么?是9补丁吗?是否正确设置了可拉伸区域?

    【讨论】:

    • 您好,谢谢您的回答。是的,你已经很好地理解了我的观点。我的drawable是一个png文件,取自res/drawables。我曾尝试在另一台设备上使用比操作栏更大的另一张图片来完成完全相同的操作,并且它以正确的方式缩放,所以我有点迷失了。
    • 好的。 png 是否已保存为 9 补丁(即它是否有 .9.png 扩展名)?另外,它实际上是一个 9 补丁文件吗?也就是你有没有用/tools/draw9patch打开文件,然后根据developer.android.com/guide/developing/tools/draw9patch.htmldeveloper.android.com/guide/topics/graphics/…编辑文件?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 2012-02-27
    • 2012-05-21
    相关资源
    最近更新 更多