public Point getLocationInWindow() { int[] outLocation = new int[2]; super.getLocationInWindow(outLocation); return new Point(outLocation[0], outLocation[1]); }
private void setLineLocation(int position) { ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v_tabline.getLayoutParams(); lp.width = tv_downloaded.getWidth(); int[] wh = new int[2]; if (position == 0) { tv_downloaded.getLocationInWindow(wh); } else if (position == 1) { tv_downloading.getLocationInWindow(wh); } lp.leftMargin = wh[0]; v_tabline.setLayoutParams(lp); }
ScrollView s = (ScrollView) findViewById(R.id.s); TextView a = (TextView) findViewById(R.id.a); s.post(new Runnable() { public void run() { int[] location = new int[2]; a.getLocationInWindow(location); int y = location[1]; s.getLocationInWindow(location); s.scrollTo(0, y-location[1]); // or some other calculation } });
@Override public void onShade(TextView textView) { //渐变 int location[] = new int[2]; textView.getLocationInWindow(location); textView.setText("国\n国"); textView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); //需要一个矩形区域,并且从canvas左上角开始计算 LinearGradient gradient = new LinearGradient(0,textView.getMeasuredHeight(),textView.getMeasuredWidth(),0,new int[]{Color.BLACK,Color.WHITE,Color.YELLOW},new float[]{0.1f,0.8f,0.1f}, Shader.TileMode.MIRROR); // LinearGradient gradient = new LinearGradient(0,textView.getTextSize(),textView.getTextSize(),0,Color.BLACK,Color.YELLOW, Shader.TileMode.REPEAT); textView.getPaint().setShader(gradient); } });
mEditButton.getLocationInWindow(coord); switch (mSide)
@Override public void onDelete(final int position, View v, ViewGroup parent) { if (position != 0) { View view = userGridView.getChildAt(position); final ImageView moveImageView = getView(view); if (moveImageView != null) { TextView newTextView = (TextView) view.findViewById(R.id.text_item); final int[] startLocation = new int[2]; newTextView.getLocationInWindow(startLocation); final ChannelItem channel = userAdapter.getItem(position);//获取点击的频道内容 otherAdapter.setVisible(false); userAdapter.setIsDeleteing(true); //添加到最后一个 otherAdapter.addItem(channel); new Handler().postDelayed(new Runnable() { public void run() { try { int[] endLocation = new int[2]; //获取终点的坐标 otherGridView.getChildAt(otherGridView.getLastVisiblePosition()).getLocationInWindow(endLocation); MoveAnim(moveImageView, startLocation , endLocation, channel,userGridView); userAdapter.setRemove(position); } catch (Exception localException) { } } }, 50L); } } } });
mUrlBar.getLocationInWindow(oldLoc);
TextView newTextView = (TextView) view.findViewById(R.id.text_item); final int[] startLocation = new int[2]; newTextView.getLocationInWindow(startLocation); final ColumnBean columnBean = ((DragGridViewAdapter) parent.getAdapter()).getItem(position);//获取点击的频道内容 mOptionalGridViewAdapter.setVisible(false); TextView newTextView = (TextView) view.findViewById(R.id.text_item); final int[] startLocation = new int[2]; newTextView.getLocationInWindow(startLocation); final ColumnBean columnBean = ((OptionalGridViewAdapter) parent.getAdapter()).getItem(position); mDragGridViewAdapter.setVisible(false);
@Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mUrlBar.removeOnLayoutChangeListener(this); int[] newLoc = new int[2]; mUrlBar.getLocationInWindow(newLoc); mUrlBar.setScaleX(scale); mUrlBar.setScaleY(scale); mUrlBar.setTranslationX(oldLoc[0] - newLoc[0]); mUrlBar.setTranslationY(oldLoc[1] - newLoc[1]); mUrlBar.animate().scaleX(1f).scaleY(1f).translationX(0).translationY(0) .setDuration(CUSTOM_TAB_TOOLBAR_SLIDE_DURATION_MS) .setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mTitleBar.animate().alpha(1f) .setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE) .setDuration(CUSTOM_TAB_TOOLBAR_FADE_DURATION_MS).start(); } }).start(); } });
TextView newTextView = (TextView) view.findViewById(R.id.text_item); final int[] startLocation = new int[2]; newTextView.getLocationInWindow(startLocation); final ChannelItem channel = ((OtherAdapter) parent.getAdapter()).getItem(position); userAdapter.setVisible(false);
tv_car.getLocationInWindow(endLocation);