如何获取当前黑莓主题的突出显示颜色?

发布于 2024-08-05 11:29:30 字数 347 浏览 2 评论 0原文

我已经实现了一些自定义字段,并希望保持外观与当前的 Blackberry 主题一致。因此,我希望字段的突出显示颜色与 BB 应用程序中使用的突出显示颜色保持一致。

我怎样才能得到这个颜色?

编辑:显然,有无法从任何 API 获取这些颜色。那么有没有一种变通的方法来获得这些颜色呢?

I've implemented some custom fields and would like to keep the look-and-feel consistent with the current Blackberry theme. So I would like the highlighting color of the fields to be consistent with the highlight color used throughout the BB apps.

How can I get the this color?

Edit: Apparently, there's no way to get those kinds of colors from any API. So is there a work-around way to getting these colors?

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

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

发布评论

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

评论(2

寄与心 2024-08-12 11:29:30

我们可以做的是测试一些自定义文本字段的drawFocus方法的颜色:

class TestField extends TextField {
    TestThemeListener mListener;
    public TestField(TestThemeListener listener) {
        super(EDITABLE | FOCUSABLE);
        setText("Hello this is a color test");
        setSelection(0, true, 10);
        mListener = listener;
    }
    protected void drawFocus(Graphics g, boolean on) {
        drawHighlightRegion(g, HIGHLIGHT_FOCUS, true, 0, 0, 50, 20);
        Bitmap bmp = new Bitmap(50, 20);
        Display.screenshot(bmp, 0, 0, 50, 20);
        int[] argbData = new int[1];
        bmp.getARGB(argbData, 0, 1, 0, 0, 1, 1);
        int focusColor = argbData[0];
        drawHighlightRegion(g, HIGHLIGHT_SELECT, true, 50, 0, 50, 20);
        Display.screenshot(bmp, 50, 0, 50, 20);
        argbData = new int[1];
        bmp.getARGB(argbData, 0, 1, 0, 0, 1, 1);
        int selectionColor = argbData[0];
        if (null != mListener) {
            mListener.themeTested(focusColor, selectionColor);
            mListener = null;
        }
    }
}

interface TestThemeListener {
    void themeTested(int focusColor, int selectionColor);
}

并在屏幕上使用它:

class Scr extends MainScreen implements TestThemeListener {
    LabelField mSelectionColorName;
    LabelField mFocusColorName;
    public Scr() {
        add(new TestField(this));
    }
    public void themeTested(int focusColor, int selectionColor) {
        add(new LabelField("Theme colors (AARRGGBB)"));
        add(new LabelField("Focus : " + focusColor));
        Bitmap bmpF = new Bitmap(100, 20);
        Graphics gF = new Graphics(bmpF);
        gF.setColor(focusColor);
        gF.fillRect(0, 0, 100, 20);
        add(new BitmapField(bmpF));
        add(new LabelField("Selection : " + selectionColor));
        Bitmap bmpS = new Bitmap(100, 20);
        Graphics gS = new Graphics(bmpS);
        gS.setColor(selectionColor);
        gS.fillRect(0, 0, 100, 20);
        add(new BitmapField(bmpS));
    }
}

颜色测试应用截图http://img188.imageshack.us/img188/8943/830001.png

What we can do is test colors on drawFocus method of some custom text field:

class TestField extends TextField {
    TestThemeListener mListener;
    public TestField(TestThemeListener listener) {
        super(EDITABLE | FOCUSABLE);
        setText("Hello this is a color test");
        setSelection(0, true, 10);
        mListener = listener;
    }
    protected void drawFocus(Graphics g, boolean on) {
        drawHighlightRegion(g, HIGHLIGHT_FOCUS, true, 0, 0, 50, 20);
        Bitmap bmp = new Bitmap(50, 20);
        Display.screenshot(bmp, 0, 0, 50, 20);
        int[] argbData = new int[1];
        bmp.getARGB(argbData, 0, 1, 0, 0, 1, 1);
        int focusColor = argbData[0];
        drawHighlightRegion(g, HIGHLIGHT_SELECT, true, 50, 0, 50, 20);
        Display.screenshot(bmp, 50, 0, 50, 20);
        argbData = new int[1];
        bmp.getARGB(argbData, 0, 1, 0, 0, 1, 1);
        int selectionColor = argbData[0];
        if (null != mListener) {
            mListener.themeTested(focusColor, selectionColor);
            mListener = null;
        }
    }
}

interface TestThemeListener {
    void themeTested(int focusColor, int selectionColor);
}

And use it on the screen:

class Scr extends MainScreen implements TestThemeListener {
    LabelField mSelectionColorName;
    LabelField mFocusColorName;
    public Scr() {
        add(new TestField(this));
    }
    public void themeTested(int focusColor, int selectionColor) {
        add(new LabelField("Theme colors (AARRGGBB)"));
        add(new LabelField("Focus : " + focusColor));
        Bitmap bmpF = new Bitmap(100, 20);
        Graphics gF = new Graphics(bmpF);
        gF.setColor(focusColor);
        gF.fillRect(0, 0, 100, 20);
        add(new BitmapField(bmpF));
        add(new LabelField("Selection : " + selectionColor));
        Bitmap bmpS = new Bitmap(100, 20);
        Graphics gS = new Graphics(bmpS);
        gS.setColor(selectionColor);
        gS.fillRect(0, 0, 100, 20);
        add(new BitmapField(bmpS));
    }
}

color test app screenshot http://img188.imageshack.us/img188/8943/830001.png

撩心不撩汉 2024-08-12 11:29:30

这工作正常,但有一个问题。该应用程序必须经过签名,并且会向用户显示一条确认信息以拍摄屏幕截图,例如“应用程序 xxx 想要拍摄屏幕截图。允许吗?”这可能会让用户烦恼。这是由于在设备类中使用安全 API 造成的。

相反,尝试从位图创建新的图形,然后在其上绘图。

class TestField : extends Field {
    int getHighlightColor() {
        Bitmap image = new Bitmap(getWidth(), getHeight());
        Graphics g = new Graphics(image).
        drawHighlightRegion(g, Field.HIGHLIGHT_FOCUS, true, 0, 0, getWidth(), getHeight());
        paint(
        argbData = new int[1];
        image.getARGB(argbData, 0, 1, 0, 0, 1, 1);
        return argbData[0];
    }
}

This works fine but there is a problem. The application must be signed and it displays a confirmation to the user to take the screen shots like "Application xxx wants to take a screen shot. Allow?" This could be annoying to the user. This is caused by using a secure API in the device class.

Instead, try creating a new Graphics from a Bitmap, then draw on it.

class TestField : extends Field {
    int getHighlightColor() {
        Bitmap image = new Bitmap(getWidth(), getHeight());
        Graphics g = new Graphics(image).
        drawHighlightRegion(g, Field.HIGHLIGHT_FOCUS, true, 0, 0, getWidth(), getHeight());
        paint(
        argbData = new int[1];
        image.getARGB(argbData, 0, 1, 0, 0, 1, 1);
        return argbData[0];
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文