本文整理汇总了Java中android.view.View.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java View.getHeight方法的具体用法?Java View.getHeight怎么用?Java View.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: captureView
import android.view.View; //导入方法依赖的package包/类
private Bitmap captureView (View view) {
int w = view.getWidth();
int h = view.getHeight();
if (w <= 0 || h <= 0) {
throw new RuntimeException("Impossible to snapshot the view: view is invalid");
}
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Bitmap childBitmapBuffer;
Canvas c = new Canvas(bitmap);
view.draw(c);
List<View> childrenList = getAllChildren(view);
for (View child : childrenList) {
if(child instanceof TextureView) {
((TextureView) child).setOpaque(false);
childBitmapBuffer = ((TextureView) child).getBitmap(child.getWidth(), child.getHeight());
c.drawBitmap(childBitmapBuffer, child.getLeft() + ((ViewGroup)child.getParent()).getLeft() + child.getPaddingLeft(), child.getTop() + ((ViewGroup)child.getParent()).getTop() + child.getPaddingTop(), null);
}
}
if (bitmap == null) {
throw new RuntimeException("Impossible to snapshot the view");
}
return bitmap;
}
示例2: isShouldHideKeyboard
import android.view.View; //导入方法依赖的package包/类
/**
* 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘,因为当用户点击EditText时则不能隐藏
*
* @param v
* @param event
* @return
*/
private boolean isShouldHideKeyboard(View v, MotionEvent event) {
if (v != null && (v instanceof EditText)) {
int[] l = {0, 0};
v.getLocationInWindow(l);
int left = l[0],
top = l[1],
bottom = top + v.getHeight(),
right = left + v.getWidth();
if (event.getX() > left && event.getX() < right && event.getY() > top && event.getY() < bottom) {
// 点击EditText的事件,忽略它。
return false;
} else {
return true;
}
}
// 如果焦点不是EditText则忽略,这个发生在视图刚绘制完,第一个焦点不在EditText上,和用户用轨迹球选择其他的焦点
return false;
}
示例3: onLayout
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
View rootView = getRootView();
int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
getWindowVisibleDisplayFrame(rect);
keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
if (UserConfig.passcodeType == 1 && (AndroidUtilities.isTablet() || getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)) {
int t = 0;
if (passwordFrameLayout.getTag() != null) {
t = (Integer) passwordFrameLayout.getTag();
}
LayoutParams layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
layoutParams.topMargin = t + layoutParams.height - keyboardHeight / 2 - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
passwordFrameLayout.setLayoutParams(layoutParams);
}
super.onLayout(changed, left, top, right, bottom);
}
示例4: isShouldHideKeyboard
import android.view.View; //导入方法依赖的package包/类
/**
* 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘,因为当用户点击EditText时则不能隐藏
*
* @param v
* @param event
* @return
*/
private boolean isShouldHideKeyboard(View v, MotionEvent event) {
if (v != null && (v instanceof EditText)) {
int[] l = {0, 0};
v.getLocationInWindow(l);
int left = l[0],
top = l[1],
bottom = top + v.getHeight(),
right = left + v.getWidth();
if (event.getX() > left && event.getX() < right
&& event.getY() > top && event.getY() < bottom) {
// 点击EditText的事件,忽略它。
return false;
} else {
return true;
}
}
// 如果焦点不是EditText则忽略,这个发生在视图刚绘制完,第一个焦点不在EditText上,和用户用轨迹球选择其他的焦点
return false;
}
示例5: getFabTranslationYForBottomNavigationBar
import android.view.View; //导入方法依赖的package包/类
private float[] getFabTranslationYForBottomNavigationBar(CoordinatorLayout parent,
FloatingActionButton fab) {
float minOffset = 0;
float viewHeight = 0;
final List<View> dependencies = parent.getDependencies(fab);
for (int i = 0, z = dependencies.size(); i < z; i++) {
final View view = dependencies.get(i);
if (view instanceof BottomNavigationBar) {
viewHeight = view.getHeight();
minOffset = Math.min(minOffset,
ViewCompat.getTranslationY(view) - viewHeight);
}
}
float[] returnValues = {minOffset, viewHeight};
return returnValues;
}
示例6: viewIdHitPosition
import android.view.View; //导入方法依赖的package包/类
public int viewIdHitPosition(MotionEvent ev, int id) {
final int x = (int) ev.getX();
final int y = (int) ev.getY();
int touchPos = mDslv.pointToPosition(x, y); // includes headers/footers
final int numHeaders = mDslv.getHeaderViewsCount();
final int numFooters = mDslv.getFooterViewsCount();
final int count = mDslv.getCount();
// Log.d("mobeta", "touch down on position " + itemnum);
// We're only interested if the touch was on an
// item that's not a header or footer.
if (touchPos != AdapterView.INVALID_POSITION && touchPos >= numHeaders
&& touchPos < (count - numFooters)) {
final View item = mDslv.getChildAt(touchPos - mDslv.getFirstVisiblePosition());
final int rawX = (int) ev.getRawX();
final int rawY = (int) ev.getRawY();
View dragBox = id == 0 ? item : (View) item.findViewById(id);
if (dragBox != null) {
dragBox.getLocationOnScreen(mTempLoc);
if (rawX > mTempLoc[0] && rawY > mTempLoc[1] &&
rawX < mTempLoc[0] + dragBox.getWidth() &&
rawY < mTempLoc[1] + dragBox.getHeight()) {
mItemX = item.getLeft();
mItemY = item.getTop();
return touchPos;
}
}
}
return MISS;
}
示例7: dismiss
import android.view.View; //导入方法依赖的package包/类
/**
* Unselected choice state in item
*/
protected int dismiss(int position) {
int start = swipeListView.getFirstVisiblePosition();
int end = swipeListView.getLastVisiblePosition();
View view = swipeListView.getChildAt(position - start);
++dismissAnimationRefCount;
if (position >= start && position <= end) {
performDismiss(view, position, false);
return view.getHeight();
} else {
pendingDismisses.add(new PendingDismissData(position, null));
return 0;
}
}
示例8: getCalculatedValueY
import android.view.View; //导入方法依赖的package包/类
@Override
public Float getCalculatedValueY(View viewToMove) {
if (vertical) {
final int centerYView1 = (int) (view1.getTop() + view1.getHeight() / 2f);
final int centerYView2 = (int) (view2.getTop() + view2.getHeight() / 2f);
return (centerYView1 + centerYView2) / 2f - viewToMove.getHeight() / 2f;
}
return null;
}
示例9: computeRatio
import android.view.View; //导入方法依赖的package包/类
private float computeRatio(RecyclerView recyclerView) {
final View child0 = recyclerView.getChildAt(0);
final int pos = recyclerView.getChildAdapterPosition(child0);
if (pos != 0) {
return 0;
}
final int height = child0.getHeight();
final float y = Math.max(0, child0.getY());
return y / height;
}
示例10: standUp
import android.view.View; //导入方法依赖的package包/类
public AnimationBuilder standUp() {
for (View view : this.views) {
float x = (float) ((((view.getWidth() - view.getPaddingLeft()) - view.getPaddingRight
()) / 2) + view.getPaddingLeft());
float y = (float) (view.getHeight() - view.getPaddingBottom());
pivotX(x, x, x, x, x);
pivotY(y, y, y, y, y);
rotationX(55.0f, -30.0f, 15.0f, -15.0f, 0.0f);
}
return this;
}
示例11: onDraw
import android.view.View; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mOpenChangeDisappearAnimation && mChangeDisappearAnimator != null &&
mChangeDisappearAnimator.isStarted() && mDetachViewsMap.size() > 0 && mIsAnimating) {
for (int i = 0; i < mDetachViewsMap.size(); i++) {
long id = mDetachViewsMap.keyAt(i);
View view = mDetachViewsMap.valueAt(i);
int newPos = getPositionForId(id);
int top, offset = (int) (mChangeDisappearPlayTime / mOffsetDurationUnit);
if (newPos < getFirstVisiblePosition()) {
top = mTopMap.get(id) - offset;
if (top < -view.getHeight()) {
continue;
}
} else {
top = mTopMap.get(id) + offset;
if (top > getHeight()) {
continue;
}
}
view.layout(0, top, view.getWidth(), top + view.getHeight());
view.setAlpha(1f - mChangeDisappearPlayTime * 1f / getChangeDisappearDuration());
// 不能直接调用view.draw(canvas), 在listview上由于缓存会冲突
drawChild(canvas, view, getDrawingTime());
}
}
}
示例12: isShouldHideInput
import android.view.View; //导入方法依赖的package包/类
/**
* 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘,因为当用户点击EditText时没必要隐藏
*
* @param v
* @param event
* @return
*/
public static boolean isShouldHideInput(View v, MotionEvent event) {
if (v != null && (v instanceof EditText)) {
int[] l = {0, 0};
v.getLocationInWindow(l);
int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left
+ v.getWidth();
return !(event.getX() > left && event.getX() < right
&& event.getY() > top && event.getY() < bottom);
}
// 如果焦点不是EditText则忽略,这个发生在视图刚绘制完,第一个焦点不在EditView上,和用户用轨迹球选择其他的焦点
return false;
}
示例13: optimizeMaxSizeByView
import android.view.View; //导入方法依赖的package包/类
/**
* @param view 图形类控件
* @param maxImageWidth 图片宽
* @param maxImageHeight 图片高
* @return 如果maxImageWidth和maxImageWidth大于0,此BitmapSize已配置,直接返回。
* 否则,根据所传控件设置BitmapSize,并返回该对象
*
*/
public static BitmapSize optimizeMaxSizeByView(View view, int maxImageWidth, int maxImageHeight) {
int width = maxImageWidth;
int height = maxImageHeight;
if (width > 0 && height > 0) {
return new BitmapSize(width, height);
}
final ViewGroup.LayoutParams params = view.getLayoutParams();
if (params != null) {
if (params.width > 0) {
width = params.width;
} else if (params.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
width = view.getWidth();
}
if (params.height > 0) {
height = params.height;
} else if (params.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
height = view.getHeight();
}
}
if (width <= 0) width = getFieldValue(view, "mMaxWidth");
if (height <= 0) height = getFieldValue(view, "mMaxHeight");
BitmapSize screenSize = getScreenSize(view.getContext());
if (width <= 0) width = screenSize.getWidth();
if (height <= 0) height = screenSize.getHeight();
return new BitmapSize(width, height);
}
示例14: transformPage
import android.view.View; //导入方法依赖的package包/类
public void transformPage(View view, float position, boolean horizontal) {
int pageSize = horizontal ? view.getWidth() : view.getHeight();
if (position < -1) { // [-Infinity,-1)way off-screen to the left
view.setAlpha(MIN_ALPHA);
view.setScaleX(MIN_SCALE);
view.setScaleY(MIN_SCALE);
} else if (position <= 1) { // [-1,1]
float percent = 1 - Math.abs(position);
float scale = MIN_SCALE + (1 - MIN_SCALE) * percent;
if (mAdjustTranslate) {
float horizontalMargin = pageSize * (1 - scale) / 2;
if (position > 0) {
if (horizontal) {
view.setTranslationX(horizontalMargin);
} else {
view.setTranslationY(horizontalMargin);
}
} else {
if (horizontal) {
view.setTranslationX(-horizontalMargin);
} else {
view.setTranslationY(-horizontalMargin);
}
}
}
view.setScaleX(scale);
view.setScaleY(scale);
view.setAlpha(MIN_ALPHA + (1 - MIN_ALPHA) * percent);
} else { // (1,+Infinity]page is way off-screen to the right.
view.setAlpha(MIN_ALPHA);
view.setScaleX(MIN_SCALE);
view.setScaleY(MIN_SCALE);
}
}
示例15: getBasicValues
import android.view.View; //导入方法依赖的package包/类
private void getBasicValues(int firstVisibleItem) {
View firstChild = getChildAt(0);
mFirstLeft = getListPaddingLeft();
mFirstTop = firstChild.getTop();
mColumnWidth = firstChild.getWidth();
mRowHeight = firstChild.getHeight();
int rowLine = firstVisibleItem / mColumnsNum;
mScrollY = mFirstTop - rowLine * (mVerticalSpacing + mRowHeight);
}