相关疑难解决方法(0)

ActionBarSherlock堆叠动作栏样式问题

我无法弄清楚为什么ActionBar我实现的堆叠在最左边的标签和屏幕边缘之间有一个间隙.

最左边的标签有左边的分隔符问题

最右边的选项卡不是这种情况.

最右边的选项卡没有分隔符问题

我试图通过造型来移除分隔线ActionBar.在玩了一点风格之后,似乎我能够覆盖TabView样式的属性而不是TabBar样式ActionBarSherlock.

<style name="ActionBarTabBarStyle.Dark" parent="@style/Widget.Sherlock.ActionBar.TabBar">
    <item name="android:divider">@null</item>
    <item name="android:showDividers">none</item>
    <item name="android:dividerPadding">0dip</item>
</style>
Run Code Online (Sandbox Code Playgroud)

然后我意识到我需要包含相同的无前缀属性.

ActionBarSherlock主题

Due to limitations in Android's theming system any theme customizations must be declared 
in two attributes. The normal android-prefixed attributes apply the theme to the native 
action bar and the unprefixed attributes are for the custom implementation. Since both 
theming APIs are exactly the same you need only reference your customizations twice rather 
than having to implement …
Run Code Online (Sandbox Code Playgroud)

android theming actionbarsherlock android-actionbar android-styles

5
推荐指数
1
解决办法
4875
查看次数

有没有办法在Android中设置动作栏背景图像?

我需要将操作栏的背景更改为自定义图像,但每次我尝试使用此代码时都不会更改任何内容.

Bitmap b =  BitmapFactory.decodeResource(getResources(), R.drawable.navbarbg);
BitmapDrawable bd = new BitmapDrawable(getResources(), b);
bar.setBackgroundDrawable(bd);
Run Code Online (Sandbox Code Playgroud)

我也尝试了这段代码,但它没有用.

Resources res = getResources();
xpp =res.getXml(R.drawable.actionbar_background);
bitmapDrawable = (BitmapDrawable) BitmapDrawable.createFromXml (res, xpp);
Run Code Online (Sandbox Code Playgroud)

actionbar_background.xml的内容是

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/navbarbg"
android:tileMode="repeat" />
Run Code Online (Sandbox Code Playgroud)

编辑:我用这个代码工作正常:

Bitmap bMap = BitmapFactory.decodeResource(res, R.drawable.action_bar_bg);
BitmapDrawable actionBarBackground = new BitmapDrawable(res, bMap);
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(actionBarBackground);
Run Code Online (Sandbox Code Playgroud)

android background bitmap bitmapfactory android-actionbar

3
推荐指数
2
解决办法
1万
查看次数