0

我想在 BlackBerry 中显示一个垂直渐变作为 ListField Row 的背景。我已经使用 shadedFillPath 函数来实现这一点,但失败了:

int[] cols = new int[]{0xFFFFFF, 0xEEEEEE,0xEEEEEE,0XDDDDDD };
int[] xInds = new int[]{0, Display.getWidth(), Display.getWidth(), 0};
int[] yInds = new int[]{focusRect.y, focusRect.y,    
this.getRowHeight()+focusRect.y,this.getRowHeight()+focusRect.y};
graphics.drawShadedFilledPath(xInds, yInds,null, cols, null);
4

2 回答 2

1

尝试这个

        int[] X_PTS = { 0, getPreferredWidth(),getPreferredWidth(),0};        
        int[] Y_PTS = { 0,0, getPreferredHeight(),getPreferredHeight()};        
        int[] drawColors = { Colors.CategoryFocusGradientStart, Colors.CategoryFocusGradientStart,
                             Colors.CategoryFocusGradientEnd, Colors.CategoryFocusGradientEnd };        
        try {            
            g.drawShadedFilledPath(X_PTS, Y_PTS, null, drawColors, null);        
        } catch (IllegalArgumentException e) {
            Log.Error(e,this,"Bad arguments.");
        }
于 2011-11-18T12:16:15.807 回答
0

它不是@rfsk2010 的答案,而是几乎(你必须为 y 更改那个 0):

进入:

public void drawListRow(ListField listField, Graphics graphics,int index, int y, int width)

做这个:

int[] X_PTS = { 0, getPreferredWidth(),getPreferredWidth(),0};        
int[] Y_PTS = { y, y, getPreferredHeight(),getPreferredHeight()};        
int[] drawColors = { Colors.CategoryFocusGradientStart, Colors.CategoryFocusGradientStart,
                     Colors.CategoryFocusGradientEnd, Colors.CategoryFocusGradientEnd };        
try {            
    graphics.drawShadedFilledPath(X_PTS, Y_PTS, null, drawColors, null);        
} catch (IllegalArgumentException e) {
    Log.Error(e,this,"Bad arguments.");
}
于 2012-02-09T09:15:43.757 回答