如何更改 Horizo​​ntalFieldManager 的背景

发布于 2024-11-07 04:09:08 字数 1800 浏览 1 评论 0原文

我想设置 Horizo​​ntalFieldManager 的背景。 我一直在搜索的示例代码是使用渐变为主屏幕背景设置背景。

 //create gradient linear for background
 this.getMainManager().setBackground(BackgroundFactory.createLinearGradientBackground(0x0099CCFF,
                            0x0099CCFF,0x00336699,0x00336699)
                        );

然后我尝试使用相同的模式将背景设置为 Horizo​​ntalFieldManager,因为它有这个方法。但这是行不通的。这是我使用 Horizo​​ntalFieldManager 并添加 4 BitmapField 的代码

            HorizontalFieldManager hManager = new HorizontalFieldManager();

    Bitmap bitmapImage = null;

    bitmapImage = Bitmap.getBitmapResource("img/home.png");
    tabHome = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
            | BitmapField.HIGHLIGHT_FOCUS);

    bitmapImage = Bitmap.getBitmapResource("img/in.png");
    tabCheckInOut = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
            | BitmapField.HIGHLIGHT_FOCUS);

    bitmapImage = Bitmap.getBitmapResource("img/barcode.png");
    tabBarcode = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
            | BitmapField.HIGHLIGHT_FOCUS);

    bitmapImage = Bitmap.getBitmapResource("img/options.png");
    tabOptions = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
            | BitmapField.HIGHLIGHT_FOCUS);

    tabHome.setFocusListener(this);
    tabCheckInOut.setFocusListener(this);
    tabBarcode.setFocusListener(this);
    tabOptions.setFocusListener(this);

    Background topBack = BackgroundFactory.createSolidBackground(0x00606A85);
    hManager.setBackground(topBack);

    hManager.add(tabHome);
    hManager.add(tabCheckInOut);
    hManager.add(tabBarcode);
    hManager.add(tabOptions);

    add(hManager);

,然后使用 BackgroundFactory 创建solidBackground,并将其设置为管理器 但是当我运行它时,背景颜色不适用。渐变示例效果很好。我有什么遗漏的吗?请帮我。

谢谢

I want to set the Background of HorizontalFieldManager.
The sample code I've been searching is setting the background using Gradient for the main screen background.

 //create gradient linear for background
 this.getMainManager().setBackground(BackgroundFactory.createLinearGradientBackground(0x0099CCFF,
                            0x0099CCFF,0x00336699,0x00336699)
                        );

Then I try to use the same pattern to set background to HorizontalFieldManager, since it have this method. But it won't work. Here's the code

            HorizontalFieldManager hManager = new HorizontalFieldManager();

    Bitmap bitmapImage = null;

    bitmapImage = Bitmap.getBitmapResource("img/home.png");
    tabHome = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
            | BitmapField.HIGHLIGHT_FOCUS);

    bitmapImage = Bitmap.getBitmapResource("img/in.png");
    tabCheckInOut = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
            | BitmapField.HIGHLIGHT_FOCUS);

    bitmapImage = Bitmap.getBitmapResource("img/barcode.png");
    tabBarcode = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
            | BitmapField.HIGHLIGHT_FOCUS);

    bitmapImage = Bitmap.getBitmapResource("img/options.png");
    tabOptions = new BitmapField(bitmapImage, BitmapField.FOCUSABLE
            | BitmapField.HIGHLIGHT_FOCUS);

    tabHome.setFocusListener(this);
    tabCheckInOut.setFocusListener(this);
    tabBarcode.setFocusListener(this);
    tabOptions.setFocusListener(this);

    Background topBack = BackgroundFactory.createSolidBackground(0x00606A85);
    hManager.setBackground(topBack);

    hManager.add(tabHome);
    hManager.add(tabCheckInOut);
    hManager.add(tabBarcode);
    hManager.add(tabOptions);

    add(hManager);

I'm using HorizontalFieldManager and add 4 BitmapField, then I using BackgroundFactory to create solidBackground, and set it to the manager
but when I run it, the background color does not apply. The gradient example work well. Is there anything that I'm missing? Please help me.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤者何惧 2024-11-14 04:09:08

在进行了一些深度网络搜索之后。这是答案,伙计们

HorizontalFieldManager manager = new HorizontalFieldManager()
{
    public void paint(Graphics graphics)
    {
        graphics.setBackgroundColor(0x000000FF);//blue
        graphics.clear();
        super.paint(graphics);
    }
};

更新:
您只能使用网页颜色
例如 0x006699FF 应该可以工作
但 0x00606A85 不起作用。
如果您想要特定的颜色,我建议您使用位图。

更新:
另一种解决方案

 HorizontalFieldManager manager = new HorizontalFieldManager(Field.USE_ALL_WIDTH);
 manager.setBackground(BackgroundFactory.BackgroundFactory
            .createSolidBackground(0x00cccccc));

After doing some deep web search. Here's the answer guys

HorizontalFieldManager manager = new HorizontalFieldManager()
{
    public void paint(Graphics graphics)
    {
        graphics.setBackgroundColor(0x000000FF);//blue
        graphics.clear();
        super.paint(graphics);
    }
};

UPDATE:
You must only use Web Color
such as 0x006699FF should work
but 0x00606A85 would not work.
if you want a specific color, i recommend you using bitmap.

UPDATE:
Another solution

 HorizontalFieldManager manager = new HorizontalFieldManager(Field.USE_ALL_WIDTH);
 manager.setBackground(BackgroundFactory.BackgroundFactory
            .createSolidBackground(0x00cccccc));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文