【发布时间】:2014-04-23 19:10:18
【问题描述】:
我在我的 Android 应用程序中使用 ActionBar,为了自定义每个选项卡,我在 ActionBar 后面放了一个背景图片,如下所示:
在我的手机上实际上它看起来不错,但在其他手机上它看起来非常挤压。如何根据背景的比例按比例缩放 ActionBar?有什么解决方案吗?我必须确定修复 DPI 中的高度,因为如果我忽略它,ActionBar 甚至都不会出现。我的样式代码现在如下;
<style name="MyActionBar" parent="android:Theme.Holo.Light">
<item name="android:backgroundStacked">@drawable/tab_bg</item>
<item name="android:adjustViewBounds">true</item>
<item name="android:scaleType">fitEnd</item>
<item name="android:height">87dp</item>
</style>
更新:
我只是不知道 Mr.T 的 xml 代码在哪里。我使用的是基本的android ActionBar,而且我只有一个名为menu.xml 的xml,但是如果我将代码放入其中,则没有效果。
我尝试使用以下样式设置操作栏,但如果我没有指定 android:height 参数,操作栏仍然为 0 并且不显示。
<style name="MyActionBar" parent="android:Theme.Light">
<item name="android:backgroundStacked">@drawable/tab_bg</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:src">@drawable/tab_bg</item>
<item name="android:scaleType">matrix</item>
</style>
操作栏在某些设备上仍然如下所示; http://i.imgur.com/yQN67J3.png
【问题讨论】:
标签: java android eclipse styles android-actionbar