android.widget.TextView.getRight()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(165)

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

TextView.getRight介绍

暂无

代码示例

代码示例来源:origin: jenly1314/WanAndroid

private boolean clickRightClear(TextView tv, MotionEvent event){
  Drawable drawableRight = tv.getCompoundDrawables()[2] ;
  if (drawableRight != null && event.getRawX() >= (tv.getRight() - drawableRight.getBounds().width())) {
    tv.setText(null);
    return true;
  }
  return false;
}

代码示例来源:origin: guanpj/JReadHub

@OnTouch(R.id.txt_new)
  boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
      Drawable drawableRight = mTxtNew.getCompoundDrawables()[2];
      if (drawableRight != null && event.getRawX() >= (mTxtNew.getRight() - drawableRight.getBounds().width())) {
        mTxtNew.setVisibility(View.GONE);
        return true;
      }
    }
    return false;
  }
}

代码示例来源:origin: Karumi/Dividers

if (x < mCurrText.getLeft() - mTabPadding) {
 mPager.setCurrentItem(mPager.getCurrentItem() - 1);
} else if (x > mCurrText.getRight() + mTabPadding) {
 mPager.setCurrentItem(mPager.getCurrentItem() + 1);

代码示例来源:origin: 103style/SpeedControl

@Override
  public void run() {
    tvLeft = textView.getLeft();
    tvTop = textView.getTop();
    tvRight = textView.getRight();
    tvBottom = textView.getBottom();
    first = false;
    textView.setText(tvLeft + "," + tvTop + "," + tvRight + "," + tvBottom);
  }
});

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

TextView tv = (TextView)findViewById(R.id.textView1);
Rect bounds = new Rect(tv.getLeft(), tv.getTop(), tv.getRight(), tv.getBottom());

代码示例来源:origin: Karumi/Dividers

@Override void updateTextPositions(int position, float positionOffset, boolean force) {
  final Rect r = mTempRect;
  int bottom = getHeight();
  int left = mCurrText.getLeft() - mTabPadding;
  int right = mCurrText.getRight() + mTabPadding;
  int top = bottom - mIndicatorHeight;

  r.set(left, top, right, bottom);

  super.updateTextPositions(position, positionOffset, force);
  mTabAlpha = (int) (Math.abs(positionOffset - 0.5f) * 2 * 0xFF);

  left = mCurrText.getLeft() - mTabPadding;
  right = mCurrText.getRight() + mTabPadding;
  r.union(left, top, right, bottom);

  invalidate(r);
 }
}

代码示例来源:origin: kingargyle/adt-leanback-support

@Override
  void updateTextPositions(int position, float positionOffset, boolean force) {
    final Rect r = mTempRect;
    int bottom = getHeight();
    int left = mCurrText.getLeft() - mTabPadding;
    int right = mCurrText.getRight() + mTabPadding;
    int top = bottom - mIndicatorHeight;

    r.set(left, top, right, bottom);

    super.updateTextPositions(position, positionOffset, force);
    mTabAlpha = (int) (Math.abs(positionOffset - 0.5f) * 2 * 0xFF);

    left = mCurrText.getLeft() - mTabPadding;
    right = mCurrText.getRight() + mTabPadding;
    r.union(left, top, right, bottom);

    invalidate(r);
  }
}

代码示例来源:origin: lovejjfg/Circle

@Override
protected void onDraw(Canvas canvas) {
  super.onDraw(canvas);
  if (isInEditMode() || tabCount == 0) {
    return;
  }
  final int height = getHeight();
  // draw indicator line
  rectPaint.setColor(indicatorColor);
  // default: line below current tab
  View currentTab = tabsContainer.getChildAt(currentPosition);
  float lineLeft = currentTab.getLeft();
  float lineRight = currentTab.getRight();
  // if there is an offset, start interpolating left and right coordinates between current and next tab
  if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
    TextView nextTab = (TextView) tabsContainer.getChildAt(currentPosition + 1);
    final float nextTabLeft = nextTab.getLeft();
    final float nextTabRight = nextTab.getRight();
    lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
    lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
  }
  if (textLengthVector == null) {
    canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
  } else {
    float pointC = (lineRight + lineLeft) / 2 - textLengthVector[currentPosition] / 2;
    float pointD = (lineRight + lineLeft) / 2 + textLengthVector[currentPosition] / 2;
    canvas.drawRect(pointC, height - indicatorHeight, pointD, height, rectPaint);
  }
}

代码示例来源:origin: Karumi/Dividers

@Override protected void onDraw(Canvas canvas) {
 super.onDraw(canvas);
 final int height = getHeight();
 final int bottom = height;
 final int left = mCurrText.getLeft() - mTabPadding;
 final int right = mCurrText.getRight() + mTabPadding;
 final int top = bottom - mIndicatorHeight;
 mTabPaint.setColor(mTabAlpha << 24 | (mIndicatorColor & 0xFFFFFF));
 canvas.drawRect(left, top, right, bottom, mTabPaint);
 if (mDrawFullUnderline) {
  mTabPaint.setColor(0xFF << 24 | (mIndicatorColor & 0xFFFFFF));
  canvas.drawRect(getPaddingLeft(), height - mFullUnderlineHeight,
    getWidth() - getPaddingRight(), height, mTabPaint);
 }
}

代码示例来源:origin: wangxp423/ViewExercise

private void invisible() {
  int cx = (ivMeinv.getLeft() + ivMeinv.getRight()) / 2;
  int cy = (ivMeinv.getTop() + ivMeinv.getBottom()) / 2;
  int initialRadius = ivMeinv.getWidth();
  Animator anim = ViewAnimationUtils.createCircularReveal(ivMeinv, cx, cy, initialRadius, 0);
  anim.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      super.onAnimationEnd(animation);
      ivMeinv.setVisibility(View.INVISIBLE);
    }
  });
  anim.start();
}

代码示例来源:origin: kingargyle/adt-leanback-support

@Override
protected void onDraw(Canvas canvas) {
  super.onDraw(canvas);
  final int height = getHeight();
  final int bottom = height;
  final int left = mCurrText.getLeft() - mTabPadding;
  final int right = mCurrText.getRight() + mTabPadding;
  final int top = bottom - mIndicatorHeight;
  mTabPaint.setColor(mTabAlpha << 24 | (mIndicatorColor & 0xFFFFFF));
  canvas.drawRect(left, top, right, bottom, mTabPaint);
  if (mDrawFullUnderline) {
    mTabPaint.setColor(0xFF << 24 | (mIndicatorColor & 0xFFFFFF));
    canvas.drawRect(getPaddingLeft(), height - mFullUnderlineHeight,
        getWidth() - getPaddingRight(), height, mTabPaint);
  }
}

代码示例来源:origin: wangxp423/ViewExercise

private void visible() {
  int cx = (ivMeinv.getLeft() + ivMeinv.getRight()) / 2;
  int cy = (ivMeinv.getTop() + ivMeinv.getBottom()) / 2;
  int initialRadius = ivMeinv.getWidth() + ivMeinv.getHeight();
  Animator anim = ViewAnimationUtils.createCircularReveal(ivMeinv, cx, cy, 0, initialRadius);
  ivMeinv.setVisibility(View.VISIBLE);
  anim.start();
}

代码示例来源:origin: DroidsOnRoids/Workcation

private static void setTextViewData(TextView view, TextResizeData data, float fontSize) {
  view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
  view.setPadding(data.paddingLeft, data.paddingTop, data.paddingRight, data.paddingBottom);
  view.setRight(view.getLeft() + data.width);
  view.setBottom(view.getTop() + data.height);
  view.setTextColor(data.textColor);
  int widthSpec = View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY);
  int heightSpec = View.MeasureSpec.makeMeasureSpec(view.getHeight(), View.MeasureSpec.EXACTLY);
  view.measure(widthSpec, heightSpec);
  view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
}

代码示例来源:origin: googlesamples/android-unsplash

private static void setTextViewData(TextView view, TextResizeData data, float fontSize) {
  view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
  view.setPadding(data.paddingLeft, data.paddingTop, data.paddingRight, data.paddingBottom);
  view.setRight(view.getLeft() + data.width);
  view.setBottom(view.getTop() + data.height);
  view.setTextColor(data.textColor);
  int widthSpec = View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY);
  int heightSpec = View.MeasureSpec.makeMeasureSpec(view.getHeight(), View.MeasureSpec.EXACTLY);
  view.measure(widthSpec, heightSpec);
  view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
}

代码示例来源:origin: xiangzhihong/gpuImage

private boolean checkMargin() {
  if (!rectFAll.contains(localRectF2)) {
    return false;
  }
  for (TextView textView : tvs) {
    if (!rectFAll.contains(textView.getLeft(), textView.getTop(), textView.getRight(), textView.getBottom())) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: tyrex-team/senslogs

int heightDiff = newHeight - oldHeight;
textView.layout(textView.getLeft() - widthDiff / 2, textView.getTop() - heightDiff / 2,
    textView.getRight() + widthDiff / 2, textView.getBottom() + heightDiff / 2);

代码示例来源:origin: canceel/flexboxlayout

space = space / 2;
assertThat(textView1.getLeft(), is(padding));
assertThat(flexboxLayout.getRight() - textView3.getRight(), is(padding));
assertTrue(space - 1 <= textView2.getLeft() - textView1.getRight() &&
    textView2.getLeft() - textView1.getRight() <= space + 1);
assertTrue(space - 1 <= textView3.getLeft() - textView2.getRight() &&
    textView3.getLeft() - textView2.getRight() <= space + 1);

代码示例来源:origin: canceel/flexboxlayout

int spaceLowerBound = textView1.getRight() + spaceAround * 2 - 1;
int spaceUpperBound = textView1.getRight() + spaceAround * 2 + 1;
assertTrue(spaceLowerBound <= textView3.getLeft() &&
    textView3.getLeft() <= spaceUpperBound);

代码示例来源:origin: canceel/flexboxlayout

int spaceUpperBound = flexboxLayout.getRight() - spaceLeftAndRight + 1;
assertTrue(
    spaceLowerBound <= textView3.getRight() && textView3.getRight() <= spaceUpperBound);

代码示例来源:origin: canceel/flexboxlayout

@Test
@FlakyTest(tolerance = TOLERANCE)
public void testAlignContent_flexEnd_flexDirection_column() throws Throwable {
  final FlexboxTestActivity activity = mActivityRule.getActivity();
  mActivityRule.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      activity.setContentView(R.layout.activity_align_content_test);
      FlexboxLayout flexboxLayout = (FlexboxLayout) activity
          .findViewById(R.id.flexbox_layout);
      flexboxLayout.setAlignContent(FlexboxLayout.ALIGN_CONTENT_FLEX_END);
      flexboxLayout.setFlexDirection(FlexboxLayout.FLEX_DIRECTION_COLUMN);
    }
  });
  FlexboxLayout flexboxLayout = (FlexboxLayout) activity.findViewById(R.id.flexbox_layout);
  assertThat(flexboxLayout.getAlignContent(), is(FlexboxLayout.ALIGN_CONTENT_FLEX_END));
  assertThat(flexboxLayout.getFlexDirection(), is(FlexboxLayout.FLEX_DIRECTION_COLUMN));
  onView(withId(R.id.text3)).check(isRightAlignedWith(withId(R.id.flexbox_layout)));
  onView(withId(R.id.text3)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
  onView(withId(R.id.text1)).check(isLeftOf(withId(R.id.text3)));
  onView(withId(R.id.text1)).check(isTopAlignedWith(withId(R.id.flexbox_layout)));
  onView(withId(R.id.text2)).check(isBelow(withId(R.id.text3)));
  TextView textView1 = (TextView) activity.findViewById(R.id.text1);
  TextView textView3 = (TextView) activity.findViewById(R.id.text3);
  assertThat(textView1.getRight(), is(flexboxLayout.getRight() - textView3.getWidth()));
}

相关文章

TextView类方法