黑莓场填补

扫码查看
本文介绍了黑莓场填补的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想垫电子邮件领域与下面的代码片段:

I'm trying to pad an email field with the following snippet:

    emailField = new BasicEditField(BasicEditField.FILTER_EMAIL|Field.FIELD_HCENTER|TextField.NO_NEWLINE|Field.HIGHLIGHT_FOCUS|Field.FOCUSABLE);
    emailField.setLabel("Email: ");
    emailField.setPadding(5, 5, 5, 5);
    emailField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(10, 10, 10, 10), 0x0083B0D7, Border.STYLE_SOLID));

有没有垫一个适当的方式,这样似乎边框和背景场之间没有保证金?

Is there a proper way to pad such that there appears no margin between the border and the field background?

推荐答案

尝试使用 setMargin(5,5,5,5)而不是 setPadding(5,5,5,5)

字段#setMargin()结果
  余量是一个字段外的区域,边界之后。它是由一个经理,因为这些重叠的合理分配利润。

字段#setPadding()结果
  填充是内容和边界之间的领域内的区域。

Field#setPadding()
Padding is the area within a field between the content and the border.

字段#SetBorder()结果
  边框是填充外边缘前场内的区域。

Field#SetBorder()
The border is the area within a field outside the padding and before the margin.

更新:结果
你是对的,用 setMargin替换 setPadding()()而已,并没有产生预期的结果。原因是边框你正在使用,更precise其厚度( 10 )和样式( STYLE_SOLID )。降低边框厚度为 3 和风格改变它的 STYLE_FILLED

UPDATE:
Your are right, replacing setPadding() with setMargin() only, didn't produced the desired result. The reason is the Border you are using, to be more precise its thickness (10) and style (STYLE_SOLID). Decrease the border thickness to 3 and change it style to STYLE_FILLED.

在上述变化

After the aforementioned changes

而现在的code片断:

And now the code snippet:

public class PlayingWithBorders extends MainScreen {
    public PlayingWithBorders() {
        super(NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL | USE_ALL_HEIGHT | USE_ALL_WIDTH);

        VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_HEIGHT | USE_ALL_WIDTH);
        vfm.setBackground(BackgroundFactory.createSolidBackground(Color.CYAN));

        BasicEditField emailField = new BasicEditField();
        emailField.setLabel("Email: ");
        emailField.setPadding(5, 5, 5, 5);
        emailField.setMargin(5, 5, 5, 5);
        emailField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x0083B0D7, Border.STYLE_FILLED));
        emailField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));

        BasicEditField passwordField = new BasicEditField();
        passwordField.setLabel("Password: ");
        passwordField.setPadding(5, 5, 5, 5);
        passwordField.setMargin(5, 5, 5, 5);
        passwordField.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x0083B0D7, Border.STYLE_FILLED));
        passwordField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));

        vfm.add(emailField);
        vfm.add(passwordField);
        add(vfm);
    }

这篇关于黑莓场填补的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 16:36
查看更多