com.vaadin.ui.Button.getWidth()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中com.vaadin.ui.Button.getWidth()方法的一些代码示例,展示了Button.getWidth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.getWidth()方法的具体详情如下:
包路径:com.vaadin.ui.Button
类名称:Button
方法名:getWidth

Button.getWidth介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

final Button button1 = (Button) findViewById(R.id.button1);
final Button button2 = (Button) findViewById(R.id.button2);

button1.post(new Runnable() {
  @Override
  public void run() {
    int width = button1.getWidth();
    button2.setWidth(width);
  }
});

代码示例来源:origin: stackoverflow.com

Button b = findViewById(R.id.button);
b.setHeight(b.getWidth() / 3);

代码示例来源:origin: stackoverflow.com

final Button btn1 = (Button) findViewById(R.id.btn1);
final Button btn2 = (Button) findViewById(R.id.btn2);
final Button btn3 = (Button) findViewById(R.id.btn3);
final Button btn4 = (Button) findViewById(R.id.btn4);
ViewTreeObserver vto = btn1.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

  @Override
  public void onGlobalLayout() {
    btn1.setHeight(btn1.getWidth()); 
    btn2.setHeight(btn1.getWidth());    
    btn3.setHeight(btn1.getWidth());
    btn4.setHeight(btn1.getWidth());
  }
});

代码示例来源:origin: org.aperteworkflow/gui-commons

public static Button link(String caption, Resource icon, Button.ClickListener listener) {
  Button b = button(caption, null, "link", listener);
  b.setIcon(icon);
  b.setWidth(b.getWidth() + 10, Sizeable.UNITS_PIXELS);
  return b;
}

代码示例来源:origin: stackoverflow.com

private Button mButtonOne;
private Button mButtonTwo;

@Override
protected void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);

  // inflate UI
  setContentView(R.layout.activity_example);

  // get references to UI elements
  mButtonOne = (Button)findViewById(R.id.button_one);
  mButtonTwo = (Button)findViewById(R.id.button_two);

  // Make buttons the same size (i.e. Button1.width = Button2.width)
  if ((mButtonOne != null) && (mButtonTwo != null))
  {
    mButtonOne.post(new Runnable()
    {
      @Override
      public void run()
      {
        mButtonOne.setWidth(mButtonTwo.getWidth());
      }
    });
  }
}

代码示例来源:origin: stackoverflow.com

public class MainActivity extends Activity {
  Button mButton;
  TextView mText;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);        

    mButton = (Button)findViewById(R.id.button);
    mText = (TextView)findViewById(R.id.text);

    updateUI();
  }

  public void updateUI() {
    int wButton = mButton.getWidth();
    int wText = mText.getWidth();

    if(wButton < wText) {
      mButton.setWidth(wText);
    } else {
      mText.setWidth(wButton);
    }
  }
}

相关文章

微信公众号

最新文章

更多