下面列出了android.view.ViewGroup#getBottom ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public boolean onDoubleTap(MotionEvent e) {
if (mDoubleClickListener != null) {
View target;
ViewGroup bottom = getBottomView();
ViewGroup surface = getSurfaceView();
if (e.getX() > bottom.getLeft() && e.getX() < bottom.getRight()
&& e.getY() > bottom.getTop()
&& e.getY() < bottom.getBottom()) {
target = bottom;
} else {
target = surface;
}
mDoubleClickListener.onDoubleClick(SwipeLayout.this,
target == surface);
}
return true;
}
@Override
public boolean onDoubleTap(MotionEvent e) {
if (mDoubleClickListener != null) {
View target;
ViewGroup bottom = getBottomView();
ViewGroup surface = getSurfaceView();
if (e.getX() > bottom.getLeft() && e.getX() < bottom.getRight()
&& e.getY() > bottom.getTop()
&& e.getY() < bottom.getBottom()) {
target = bottom;
} else {
target = surface;
}
mDoubleClickListener.onDoubleClick(SwipeLayoutConv.this,
target == surface);
}
return true;
}
@Override
public void onCommentItemClick(View view, String id, int shareMessagePosition, int position, String replyUser) {
LogUtil.e("位置" + shareMessagePosition);
currentPosition = shareMessagePosition;
currentCommentPosition = position;
ViewParent viewParent = view.getParent();
if (viewParent != null) {
ViewGroup parent = (ViewGroup) viewParent;
commentItemOffset += parent.getHeight() - view.getBottom();
if (parent.getParent() != null) {
ViewGroup rootParent = (ViewGroup) parent.getParent();
commentItemOffset += rootParent.getHeight() + parent.getBottom();
}
}
this.replyUid = replyUser;
dealBottomView(true);
}
@Override
public void onCommentItemClick(View view, String id, int shareMessagePosition, int commentPosition, String replyUid) {
LogUtil.e("位置" + shareMessagePosition);
currentPosition = shareMessagePosition;
currentCommentPosition = commentPosition;
ViewParent viewParent = view.getParent();
if (viewParent != null) {
ViewGroup parent = (ViewGroup) viewParent;
commentItemOffset += parent.getHeight() - view.getBottom();
if (parent.getParent() != null) {
ViewGroup rootParent = (ViewGroup) parent.getParent();
commentItemOffset += rootParent.getHeight() + parent.getBottom();
}
}
this.replyUid = replyUid;
dealBottomView(true);
}
private void calculateHintBlockPosition(ViewGroup parent, Shape shape) {
if (targetView == NO_TARGETVIEW) {
hintBlockPosition = HintCase.HINT_BLOCK_POSITION_CENTER;
} else {
int[] areas = new int[4];
areas[HintCase.HINT_BLOCK_POSITION_LEFT] = shape.getLeft() - parent.getLeft();
areas[HintCase.HINT_BLOCK_POSITION_TOP] = shape.getTop() - parent.getTop();
areas[HintCase.HINT_BLOCK_POSITION_RIGHT] = parent.getRight() - shape.getRight();
areas[HintCase.HINT_BLOCK_POSITION_BOTTOM] = parent.getBottom() - shape.getBottom();
hintBlockPosition = HintCase.HINT_BLOCK_POSITION_LEFT;
for(int i = 1; i < areas.length; i++) {
if(areas[i] >= areas[hintBlockPosition]) {
hintBlockPosition = i;
}
}
}
}
@Override
public boolean onDoubleTap(MotionEvent e) {
if(mDoubleClickListener != null){
View target;
ViewGroup bottom = getBottomView();
ViewGroup surface = getSurfaceView();
if(e.getX() > bottom.getLeft() && e.getX() < bottom.getRight()
&& e.getY() > bottom.getTop() && e.getY() < bottom.getBottom()){
target = bottom;
}else{
target = surface;
}
mDoubleClickListener.onDoubleClick(SwipeLayout.this, target == surface);
}
return true;
}
private void drawDivider(int expPosition, Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
} else {
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}
/** Scroll the layout so that the focused child is on screen. */
private void requestChildFocus() {
ViewGroup parent = (ViewGroup) mLayout.getParent();
if (mLayout.getParent() == null) return;
// Scroll the parent to make the focused child visible.
if (mFocusedChild != null) parent.requestChildFocus(mLayout, mFocusedChild);
// {@link View#requestChildFocus} fails to account for children changing their height, so
// the scroll value may be past the actual maximum.
int viewportHeight = parent.getBottom() - parent.getTop();
int scrollMax = Math.max(0, mLayout.getMeasuredHeight() - viewportHeight);
if (parent.getScrollY() > scrollMax) parent.setScrollY(scrollMax);
}
/** Scroll the layout so that the focused child is on screen. */
private void requestChildFocus() {
ViewGroup parent = (ViewGroup) mLayout.getParent();
if (mLayout.getParent() == null) return;
// Scroll the parent to make the focused child visible.
if (mFocusedChild != null) parent.requestChildFocus(mLayout, mFocusedChild);
// {@link View#requestChildFocus} fails to account for children changing their height, so
// the scroll value may be past the actual maximum.
int viewportHeight = parent.getBottom() - parent.getTop();
int scrollMax = Math.max(0, mLayout.getMeasuredHeight() - viewportHeight);
if (parent.getScrollY() > scrollMax) parent.setScrollY(scrollMax);
}
private void drawDivider(int expPosition, Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
} else {
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}
/** Scroll the layout so that the focused child is on screen. */
private void requestChildFocus() {
ViewGroup parent = (ViewGroup) mLayout.getParent();
if (mLayout.getParent() == null) return;
// Scroll the parent to make the focused child visible.
if (mFocusedChild != null) parent.requestChildFocus(mLayout, mFocusedChild);
// {@link View#requestChildFocus} fails to account for children changing their height, so
// the scroll value may be past the actual maximum.
int viewportHeight = parent.getBottom() - parent.getTop();
int scrollMax = Math.max(0, mLayout.getMeasuredHeight() - viewportHeight);
if (parent.getScrollY() > scrollMax) parent.setScrollY(scrollMax);
}
private void drawDivider(int expPosition, Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
} else {
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}
private void drawDivider(int expPosition, Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
} else {
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}
private void drawDivider(int expPosition, Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
} else {
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}
private void drawDivider(int expPosition, Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
} else {
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}
private void drawDivider(int expPosition, Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
} else {
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}
private void drawDivider(int expPosition, Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
} else {
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}
private void drawDivider(int expPosition, @NonNull Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d(tag, "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
} else {
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d(tag, "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}
private void drawDivider(int expPosition, Canvas canvas) {
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
if (divider != null && dividerHeight != 0) {
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null) {
final int left = getPaddingLeft();
final int right = getWidth() - getPaddingRight();
final int top;
final int bottom;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos) {
top = expItem.getTop() + childHeight;
bottom = top + dividerHeight;
} else {
bottom = expItem.getBottom() - childHeight;
top = bottom - dividerHeight;
}
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(left, top, right, bottom);
divider.setBounds(left, top, right, bottom);
divider.draw(canvas);
canvas.restore();
}
}
}
private void drawDivider(int expPosition, Canvas canvas)
{
final Drawable divider = getDivider();
final int dividerHeight = getDividerHeight();
// Log.d("mobeta", "div="+divider+" divH="+dividerHeight);
if (divider != null && dividerHeight != 0)
{
final ViewGroup expItem = (ViewGroup) getChildAt(expPosition
- getFirstVisiblePosition());
if (expItem != null)
{
final int l = getPaddingLeft();
final int r = getWidth() - getPaddingRight();
final int t;
final int b;
final int childHeight = expItem.getChildAt(0).getHeight();
if (expPosition > mSrcPos)
{
t = expItem.getTop() + childHeight;
b = t + dividerHeight;
}
else
{
b = expItem.getBottom() - childHeight;
t = b - dividerHeight;
}
// Log.d("mobeta", "l="+l+" t="+t+" r="+r+" b="+b);
// Have to clip to support ColorDrawable on <= Gingerbread
canvas.save();
canvas.clipRect(l, t, r, b);
divider.setBounds(l, t, r, b);
divider.draw(canvas);
canvas.restore();
}
}
}