android.widget.Button.getLeft()方法的使用及代码示例

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

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

Button.getLeft介绍

暂无

代码示例

代码示例来源:origin: SmartisanTech/SmartisanOS-SDK

@Override
public void onClick(View view) {
  if (mOneStepHelper.isOneStepShowing()) {
    mTextDragPopupWindow = mOneStepHelper.showDragPopupText(btn_show_popup,
        dragListener,
        "One Step",
        btn_show_popup.getLeft(),
        btn_show_popup.getTop());
  }
}

代码示例来源:origin: jclehner/rxdroid

@Override
  public void onShow(DialogInterface dialogInterface)
  {
    final AlertDialog dialog = (AlertDialog) dialogInterface;
    final Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE);
    final Button negativeButton = dialog.getButton(Dialog.BUTTON_NEGATIVE);
    // Before Honeycomb, the positive button was on the left. For our purposes,
    // we want the 'next' button to be on the right, and the 'back' button on
    // the left.
    // In case some locale uses the exact opposite, we dynamically check the
    // buttons' locations each time.
    if(positiveButton.getLeft() < negativeButton.getLeft())
    {
      mBackButton = positiveButton;
      mNextButton = negativeButton;
    }
    else
    {
      mBackButton = negativeButton;
      mNextButton = positiveButton;
    }
    mBackButton.setOnClickListener(mOnBtnClickListener);
    mNextButton.setOnClickListener(mOnBtnClickListener);
    final TimePeriod value = getValue();
    mBegin = value.begin();
    mEnd = value.end();
    onPageChanged(0);
  }
};

代码示例来源:origin: codechimp-org/AppRater

@Override
  public void onShow(DialogInterface dialog) {
    try {
      final Button buttonPositive = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
      if (buttonPositive == null) {
        return;
      }
      LinearLayout linearLayout = (LinearLayout)buttonPositive.getParent();
      if (linearLayout == null) {
        return;
      }
      // Check positive button not fits in window
      boolean shouldUseVerticalLayout = false;
      if (buttonPositive.getLeft() + buttonPositive.getWidth() > linearLayout.getWidth()) {
        shouldUseVerticalLayout = true;
      }
      // Change layout orientation to vertical
      if (shouldUseVerticalLayout ) {
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.setGravity(Gravity.END);
      }
    } catch (Exception ignored) {
    }
  }
});

代码示例来源:origin: AndBible/and-bible

/** calculate button position relative to this table because MotionEvents are relative to this table
 */
private void recordButtonPositions() {
  for (ButtonInfo buttonInfo : buttonInfoList) {
    
    // get position of button within row
    Button button = buttonInfo.button;
    TableRow tableRow = (TableRow)button.getParent();
    
    buttonInfo.left += button.getLeft()+tableRow.getLeft();
    buttonInfo.top += button.getTop()+tableRow.getTop();
    buttonInfo.right += button.getRight()+tableRow.getLeft();
    buttonInfo.bottom += button.getBottom()+tableRow.getTop();
  }
  
  // calculate offset of 2 button heights so users can see the buttons surrounding the current button pressed
  if (buttonInfoList.size()>0) {
    ButtonInfo but1 = buttonInfoList.get(0);
    mPreviewOffset = but1.top - but1.bottom;
  }
}
/**

代码示例来源:origin: wasdennnoch/AndroidN-ify

private void revealTheButton(Button v) {
  XposedHook.logD("androidn_ify", "reveal");
  mSelectedContainer.setVisibility(View.VISIBLE);
  int centerX = v.getLeft() + v.getWidth() / 2;
  int centerY = v.getTop() + v.getHeight() / 2;
  Animator reveal = ViewAnimationUtils.createCircularReveal( // TODO work out why this isn't working, same for hide
      mSelectedContainer,
      centerX,
      centerY,
      0,
      Math.max(centerX, mSelectedContainer.getWidth() - centerX)
          + Math.max(centerY, mSelectedContainer.getHeight() - centerY));
  reveal.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      mButton.setVisibility(View.INVISIBLE);
    }
  });
  reveal.start();
  //animateHintText(mSelectedLabel, v, reveal);
  animateHintText(mLaunchHint, v, reveal);
  mSelectedLabel.setText(v.getText());
  mLayout.postDelayed(mHideRunnable, HIDE_DELAY);
  mLayout.postDelayed(mRippleRunnable, RIPPLE_PAUSE / 2);
  // Transfer focus from the originally clicked button to the expanded button.
  mSelectedContainer.requestFocus();
}

代码示例来源:origin: THEONE10211024/ApiDemos

/**
 * The name 'test preconditions' is a convention to signal that if this
 * test doesn't pass, the test case was not set up properly and it might
 * explain any and all failures in other tests.  This is not guaranteed
 * to run before other tests, as junit uses reflection to find the tests.
 */
@SmallTest
public void testPreconditions() {
  assertNotNull(mLeftButton);
  assertTrue("center button should be right of left button",
      mLeftButton.getRight() < mCenterButton.getLeft());
  assertTrue("right button should be right of center button",
      mCenterButton.getRight() < mRightButton.getLeft());
}

代码示例来源:origin: qiubiteme/android_api_demos

/**
 * The name 'test preconditions' is a convention to signal that if this
 * test doesn't pass, the test case was not set up properly and it might
 * explain any and all failures in other tests.  This is not guaranteed
 * to run before other tests, as junit uses reflection to find the tests.
 */
@SmallTest
public void testPreconditions() {
  assertNotNull(mLeftButton);
  assertTrue("center button should be right of left button",
      mLeftButton.getRight() < mCenterButton.getLeft());
  assertTrue("right button should be right of center button",
      mCenterButton.getRight() < mRightButton.getLeft());
}

代码示例来源:origin: qiubiteme/android_api_demos

/**
 * The name 'test preconditions' is a convention to signal that if this
 * test doesn't pass, the test case was not set up properly and it might
 * explain any and all failures in other tests.  This is not guaranteed
 * to run before other tests, as junit uses reflection to find the tests.
 */
@MediumTest
public void testPreconditions() {
  assertTrue("center button should be right of left button",
      mLeftButton.getRight() < mCenterButton.getLeft());
  assertTrue("right button should be right of center button",
      mCenterButton.getRight() < mRightButton.getLeft());
  assertTrue("left button should be focused", mLeftButton.isFocused());
}

代码示例来源:origin: THEONE10211024/ApiDemos

/**
 * The name 'test preconditions' is a convention to signal that if this
 * test doesn't pass, the test case was not set up properly and it might
 * explain any and all failures in other tests.  This is not guaranteed
 * to run before other tests, as junit uses reflection to find the tests.
 */
@MediumTest
public void testPreconditions() {
  assertTrue("center button should be right of left button",
      mLeftButton.getRight() < mCenterButton.getLeft());
  assertTrue("right button should be right of center button",
      mCenterButton.getRight() < mRightButton.getLeft());
  assertTrue("left button should be focused", mLeftButton.isFocused());
}

相关文章

Button类方法