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

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

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

TextView.getHeight介绍

暂无

代码示例

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

final TextView tv = (TextView)findViewById(R.id.venueLabel);
final ViewTreeObserver observer= tv.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
      @Override
      public void onGlobalLayout() {
       tv.getHeight()
       observer.removeGlobalOnLayoutListener(this);
      }
    });

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

TextView tv = (TextView)findViewById(R.id.image_test);
 LayerDrawable ld = (LayerDrawable)tv.getBackground();
 int topInset = tv.getHeight() / 2 ; //does not work!
 ld.setLayerInset(1, 0, topInset, 0, 0);
 tv.setBackgroundDrawable(ld);

代码示例来源:origin: Manabu-GT/ExpandableTextView

@Override
  public void run() {
    mMarginBetweenTxtAndBottom = getHeight() - mTv.getHeight();
  }
});

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

final TextView tv = (TextView)findViewById(R.id.image_test);
   ViewTreeObserver vto = tv.getViewTreeObserver();
   vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
     @Override
     public void onGlobalLayout() {
       LayerDrawable ld = (LayerDrawable)tv.getBackground();
       ld.setLayerInset(1, 0, tv.getHeight() / 2, 0, 0);
     }
   });

代码示例来源:origin: Rukey7/MvpApp

@Override
  public void run() {
    mLovedAnimator = AnimateHelper.doHappyJump(mIvCount, mIvCount.getHeight() * 2/3, 3000);
  }
});

代码示例来源:origin: jaydenxiao2016/AndroidFire

@Override
  public void run() {
    mMarginBetweenTxtAndBottom = getHeight() - mTvContent.getHeight();
  }
});

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

final TextView tv = (TextView)findViewById(R.id.image_test);
ViewTreeObserver vto = tv.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

  @Override
  public void onGlobalLayout() {
    LayerDrawable ld = (LayerDrawable)tv.getBackground();
    ld.setLayerInset(1, 0, tv.getHeight() / 2, 0, 0);
    ViewTreeObserver obs = tv.getViewTreeObserver();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      obs.removeOnGlobalLayoutListener(this);
    } else {
      obs.removeGlobalOnLayoutListener(this);
    }
  }

});

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

public void onCreate() {
setContentView(R.layout.main);

final TextView tv = (TextView)findViewById(R.id.image_test);
final LayerDrawable ld = (LayerDrawable)tv.getBackground();
final ViewTreeObserver obs = mTv.getViewTreeObserver();
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
  @Override
  public boolean onPreDraw () {
    Log.d(TAG, "onPreDraw tv height is " + tv.getHeight()); // bad for performance, remove on production
    int height = tv.getHeight();
    int topInset = height / 2;
    ld.setLayerInset(1, 0, topInset, 0, 0);
    tv.setBackgroundDrawable(ld);

    return true;
  }
});
}

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

final TextView tv = (TextView)findViewById(R.id.image_test);
ViewTreeObserver vto = tv.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
  @Override
  public void onGlobalLayout() {
    LayerDrawable ld = (LayerDrawable)tv.getBackground();
    ld.setLayerInset(1, 0, tv.getHeight() / 2, 0, 0);
  }
});

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

private int mLastTvHeight = 0;

public void onCreate() {
setContentView(R.layout.main);

final TextView tv = (TextView)findViewById(R.id.image_test);
final LayerDrawable ld = (LayerDrawable)tv.getBackground();
final ViewTreeObserver obs = mTv.getViewTreeObserver();
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
  @Override
  public boolean onPreDraw () {
    Log.d(TAG, "onPreDraw tv height is " + tv.getHeight()); // bad for performance, remove on production
    int height = tv.getHeight();
    if (height != mLastTvHeight) {
      mLastTvHeight = height;
      int topInset = height / 2;
      ld.setLayerInset(1, 0, topInset, 0, 0);
      tv.setBackgroundDrawable(ld);
    }

    return true;
  }
});
}

代码示例来源:origin: naman14/Timber

private void setBubbleAndHandlePosition(float y) {
  int bubbleHeight = bubble.getHeight();
  int handleHeight = handle.getHeight();
  handle.setY(getValueInRange(0, height - handleHeight, (int) (y - handleHeight / 2)));
  bubble.setY(getValueInRange(0, height - bubbleHeight - handleHeight / 2, (int) (y - bubbleHeight)));
}

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

p.topMargin = iv.getHeight() - tvTitle.getHeight(); 
llMainHolder.setLayoutParams(p);

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

nextTextView.setTranslationY(nextTextView.getHeight());
nextTextView.animate().translationY(0).setDuration(ANIMATION_DURATION).setListener(new Animator.AnimatorListener() {
  @Override
nextTextView.setTranslationY(-nextTextView.getHeight());
nextTextView.animate().translationY(0).setDuration(ANIMATION_DURATION).setListener(new Animator.AnimatorListener() {
  @Override

代码示例来源:origin: jaydenxiao2016/AndroidFire

} else {
  valueAnimator = new ValueAnimator().ofInt(getHeight(), getHeight() +
      mTextHeightWithMaxLines - mTvContent.getHeight());

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

int bubbleHeight=bubble.getHeight();
int handleHeight=handle.getHeight();
handle.setY(getValueInRange(0,height-handleHeight,(int)(y-handleHeight/2)));

代码示例来源:origin: roughike/BottomBar

private void updateTitleBottomPadding() {
  if (isIconsOnlyMode()) {
    return;
  }
  int tabCount = getTabCount();
  if (tabContainer == null || tabCount == 0 || !isShiftingMode()) {
    return;
  }
  for (int i = 0; i < tabCount; i++) {
    BottomBarTab tab = getTabAtPosition(i);
    TextView title = tab.getTitleView();
    if (title == null) {
      continue;
    }
    int baseline = title.getBaseline();
    int height = title.getHeight();
    int paddingInsideTitle = height - baseline;
    int missingPadding = tenDp - paddingInsideTitle;
    if (missingPadding > 0) {
      title.setPadding(title.getPaddingLeft(), title.getPaddingTop(),
          title.getPaddingRight(), missingPadding + title.getPaddingBottom());
    }
  }
}

代码示例来源:origin: Manabu-GT/ExpandableTextView

} else {
  animation = new ExpandCollapseAnimation(this, getHeight(), getHeight() +
      mTextHeightWithMaxLines - mTv.getHeight());

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

mTextView.getHeight(),
mTextView.getPaint(),
mTextView.getLineSpacingMultiplier(),

代码示例来源:origin: seven332/EhViewer

widget.getTotalPaddingBottom();
int areatop = widget.getScrollY();
int areabot = areatop + widget.getHeight() - padding;

代码示例来源:origin: AAkira/ExpandableLayout

@Override
  public void onGlobalLayout() {
    mExpandLayout.move(mOverlayText.getHeight(), 0, null);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
      mOverlayText.getViewTreeObserver().removeGlobalOnLayoutListener(mGlobalLayoutListener);
    } else {
      mOverlayText.getViewTreeObserver().removeOnGlobalLayoutListener(mGlobalLayoutListener);
    }
  }
};

相关文章

TextView类方法