本文整理了Java中android.widget.ImageView.getMeasuredWidth()
方法的一些代码示例,展示了ImageView.getMeasuredWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.getMeasuredWidth()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:getMeasuredWidth
暂无
代码示例来源:origin: stackoverflow.com
int finalHeight, finalWidth;
final ImageView iv = (ImageView)findViewById(R.id.scaled_image);
final TextView tv = (TextView)findViewById(R.id.size_label);
ViewTreeObserver vto = iv.getViewTreeObserver();
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
iv.getViewTreeObserver().removeOnPreDrawListener(this);
finalHeight = iv.getMeasuredHeight();
finalWidth = iv.getMeasuredWidth();
tv.setText("Height: " + finalHeight + " Width: " + finalWidth);
return true;
}
});
代码示例来源:origin: stackoverflow.com
int finalHeight, finalWidth;
final ImageView iv = (ImageView)findViewById(R.id.scaled_image);
final TextView tv = (TextView)findViewById(R.id.size_label);
ViewTreeObserver vto = iv.getViewTreeObserver();
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
// Remove after the first run so it doesn't fire forever
iv.getViewTreeObserver().removeOnPreDrawListener(this);
finalHeight = iv.getMeasuredHeight();
finalWidth = iv.getMeasuredWidth();
tv.setText("Height: " + finalHeight + " Width: " + finalWidth);
return true;
}
});
代码示例来源:origin: Clans/FloatingActionButton
menuButtonTop + mMenuButton.getMeasuredHeight());
int imageLeft = buttonsHorizontalCenter - mImageToggle.getMeasuredWidth() / 2;
int imageTop = menuButtonTop + mMenuButton.getMeasuredHeight() / 2 - mImageToggle.getMeasuredHeight() / 2;
mImageToggle.layout(imageLeft, imageTop, imageLeft + mImageToggle.getMeasuredWidth(),
imageTop + mImageToggle.getMeasuredHeight());
代码示例来源:origin: stackoverflow.com
ImageView iv=(ImageView)findViewById(R.id.image);
ViewTreeObserver vto = iv.getViewTreeObserver();
vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
finalHeight = iv.getMeasuredHeight();
finalWidth = iv.getMeasuredWidth();
Log.e("hilength","Height: " + finalHeight + " Width: " + finalWidth);
return true;
}
});
代码示例来源:origin: chaychan/TouTiao
@Override
public void run() {
//设置最小宽度,使其可以在滑动一部分距离
ViewGroup slidingTabStrip = (ViewGroup) mTabChannel.getChildAt(0);
slidingTabStrip.setMinimumWidth(slidingTabStrip.getMeasuredWidth() + ivAddChannel.getMeasuredWidth());
}
});
代码示例来源:origin: chaychan/TouTiao
@Override
public void run() {
//设置最小宽度,使其可以在滑动一部分距离
ViewGroup slidingTabStrip = (ViewGroup) mTabChannel.getChildAt(0);
slidingTabStrip.setMinimumWidth(slidingTabStrip.getMeasuredWidth() + mIvOperation.getMeasuredWidth());
}
});
代码示例来源:origin: stackoverflow.com
newRot = rotation(event);
float r = newRot - d;
matrix.postRotate(r, view.getMeasuredWidth() / 2,
view.getMeasuredHeight() / 2);
代码示例来源:origin: chaychan/TouTiao
@Override
public void onDismiss(DialogInterface dialog) {
mChannelPagerAdapter.notifyDataSetChanged();
mVpContent.setOffscreenPageLimit(mSelectedChannels.size());
mTabChannel.setCurrentItem(mTabChannel.getSelectedTabPosition());
ViewGroup slidingTabStrip = (ViewGroup) mTabChannel.getChildAt(0);
//注意:因为最开始设置了最小宽度,所以重新测量宽度的时候一定要先将最小宽度设置为0
slidingTabStrip.setMinimumWidth(0);
slidingTabStrip.measure(0, 0);
slidingTabStrip.setMinimumWidth(slidingTabStrip.getMeasuredWidth() + ivAddChannel.getMeasuredWidth());
//保存选中和未选中的channel
PreUtils.putString(Constant.SELECTED_CHANNEL_JSON, mGson.toJson(mSelectedChannels));
PreUtils.putString(Constant.UNSELECTED_CHANNEL_JSON, mGson.toJson(mUnSelectedChannels));
}
});
代码示例来源:origin: skydoves/ColorPickerView
/**
* gets a selector's selected coordinate x.
*
* @return a selected coordinate x.
*/
public float getSelectorX() {
return selector.getX() - (selector.getMeasuredWidth() / 2);
}
代码示例来源:origin: skydoves/ColorPickerView
/**
* gets center coordinate of the selector.
*
* @param x coordinate x.
* @param y coordinate y.
* @return the center coordinate of the selector.
*/
private Point getCenterPoint(int x, int y) {
return new Point(
x - (selector.getMeasuredWidth() / 2), y - (selector.getMeasuredHeight() / 2));
}
代码示例来源:origin: stackoverflow.com
final ImageView iv = (ImageView)findViewById(R.id.scaled_image);
iv.post(new Runnable() {
@Override
public void run() {
int width = iv.getMeasuredWidth();
int height = iv.getMeasuredHeight();
}
});
代码示例来源:origin: WangShuo1143368701/VideoView
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
params.x = (int) (motionEvent.getRawX() - mCaptureIv.getMeasuredWidth() / 2);
params.y = (int) (motionEvent.getRawY() - mCaptureIv.getMeasuredHeight() / 2 - 20);
wm.updateViewLayout(mCaptureLl, params);
return false;
}
});
代码示例来源:origin: adolfAn/FBReader_AS
protected void moveCursor() {
float y = viewHue.getMeasuredHeight() - (getHue() * viewHue.getMeasuredHeight() / 360.f);
if (y == viewHue.getMeasuredHeight()) y = 0.f;
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) viewCursor.getLayoutParams();
layoutParams.leftMargin = (int) (viewHue.getLeft() - Math.floor(viewCursor.getMeasuredWidth() / 2) - viewContainer.getPaddingLeft());
;
layoutParams.topMargin = (int) (viewHue.getTop() + y - Math.floor(viewCursor.getMeasuredHeight() / 2) - viewContainer.getPaddingTop());
;
viewCursor.setLayoutParams(layoutParams);
}
代码示例来源:origin: SwiftyWang/FingerColoring-Android
@Override
public void onLoadingStarted(String s, View view) {
tag.setImageResource(R.drawable.ic_autorenew_black_24dp);
tag.startAnimation(AnimateFactory.getInstance().rotateAnimationForever(0, 360, tag.getMeasuredWidth() / 2, tag.getMeasuredHeight() / 2));
}
代码示例来源:origin: skydoves/ColorPickerView
public void updateSelectorX(int x) {
float left = selector.getMeasuredWidth();
float right = getMeasuredWidth() - selector.getMeasuredWidth();
selectorPosition = (x - left) / (right - left);
selector.setX(x - (selector.getMeasuredWidth() / 2));
selectedX = x;
int maxPos = getMeasuredWidth() - selector.getMeasuredWidth();
if (selector.getX() >= maxPos) selector.setX(maxPos);
if (selector.getX() <= 0) selector.setX(0);
colorPickerView.fireColorListener(assembleColor(), false);
}
代码示例来源:origin: xuehuayous/PullToRefresh-Demo
@Override
public void onPull(float scaleOfLayout) {
scaleOfLayout = scaleOfLayout > 1.0f ? 1.0f : scaleOfLayout;
//缩放动画
ViewHelper.setPivotY(mBabyImage, mBabyImage.getMeasuredHeight()); // 设置中心点
ViewHelper.setPivotX(mBabyImage, mBabyImage.getMeasuredWidth() / 2);
ObjectAnimator animPX = ObjectAnimator.ofFloat(mBabyImage, "scaleX", 0, 1).setDuration(300);
animPX.setCurrentPlayTime((long) (scaleOfLayout * 300));
ObjectAnimator animPY = ObjectAnimator.ofFloat(mBabyImage, "scaleY", 0, 1).setDuration(300);
animPY.setCurrentPlayTime((long) (scaleOfLayout * 300));
}
代码示例来源:origin: skydoves/ColorPickerView
/**
* changes selector's selected point without notifies.
*
* @param x coordinate x of the selector.
* @param y coordinate y of the selector.
*/
public void setCoordinate(int x, int y) {
selector.setX(x - (selector.getMeasuredWidth() / 2));
selector.setY(y - (selector.getMeasuredHeight() / 2));
}
代码示例来源:origin: yukuku/androidbible
protected void moveTarget() {
float x = getSat() * viewSatVal.getMeasuredWidth();
float y = (1.f - getVal()) * viewSatVal.getMeasuredHeight();
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) viewTarget.getLayoutParams();
layoutParams.leftMargin = (int) (viewSatVal.getLeft() + x - Math.floor(viewTarget.getMeasuredWidth() / 2) - viewContainer.getPaddingLeft());
layoutParams.topMargin = (int) (viewSatVal.getTop() + y - Math.floor(viewTarget.getMeasuredHeight() / 2) - viewContainer.getPaddingTop());
viewTarget.setLayoutParams(layoutParams);
}
代码示例来源:origin: skydoves/ColorPickerView
@Override
public void onInflateFinished() {
int defaultPosition = getMeasuredWidth() - selector.getMeasuredWidth();
if (getPreferenceName() != null) {
updateSelectorX(
ColorPickerPreferenceManager.getInstance(getContext())
.getBrightnessSliderPosition(getPreferenceName(), defaultPosition));
} else {
selector.setX(defaultPosition);
}
}
代码示例来源:origin: skydoves/ColorPickerView
@Override
public void onInflateFinished() {
int defaultPosition = getMeasuredWidth() - selector.getMeasuredWidth();
if (getPreferenceName() != null) {
updateSelectorX(
ColorPickerPreferenceManager.getInstance(getContext())
.getAlphaSliderPosition(getPreferenceName(), defaultPosition));
} else {
selector.setX(defaultPosition);
}
}
内容来源于网络,如有侵权,请联系作者删除!