同步2.2修改
This commit is contained in:
@ -17,7 +17,7 @@ public class CardRelativeLayout extends RelativeLayout {
|
||||
|
||||
private int mLeft, mTop, mRight, mBottom;
|
||||
|
||||
private boolean isTran;
|
||||
private boolean isTran, isReverse;
|
||||
|
||||
public CardRelativeLayout(Context context) {
|
||||
this(context, null);
|
||||
@ -42,13 +42,14 @@ public class CardRelativeLayout extends RelativeLayout {
|
||||
mRight = ta.getDimensionPixelSize(R.styleable.CardLayout_right, 0);
|
||||
mBottom = ta.getDimensionPixelSize(R.styleable.CardLayout_bottom, 0);
|
||||
isTran = ta.getBoolean(R.styleable.CardLayout_tran, false);
|
||||
isReverse = ta.getBoolean(R.styleable.CardLayout_reverse, true);
|
||||
ta.recycle();
|
||||
}
|
||||
|
||||
if (isTran) {
|
||||
mLeftDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_left);
|
||||
mRightDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_right);
|
||||
topDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_top);
|
||||
mRightDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_right);
|
||||
bottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_bottom);
|
||||
|
||||
leftTopDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_left_top_square);
|
||||
@ -57,8 +58,8 @@ public class CardRelativeLayout extends RelativeLayout {
|
||||
rightBottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_right_bottom_square);
|
||||
} else {
|
||||
mLeftDrawable = getContext().getResources().getDrawable(R.drawable.frame_left);
|
||||
mRightDrawable = getContext().getResources().getDrawable(R.drawable.frame_right);
|
||||
topDrawable = getContext().getResources().getDrawable(R.drawable.frame_top);
|
||||
mRightDrawable = getContext().getResources().getDrawable(R.drawable.frame_right);
|
||||
bottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_bottom);
|
||||
|
||||
leftTopDrawable = getContext().getResources().getDrawable(R.drawable.frame_left_top_square);
|
||||
@ -71,48 +72,84 @@ public class CardRelativeLayout extends RelativeLayout {
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (mLeft != 0) {
|
||||
if (mLeftDrawable != null) {
|
||||
mLeftDrawable.setBounds(0, mTop, mLeft, getHeight() - mBottom);
|
||||
mLeftDrawable.draw(canvas);
|
||||
if (!isReverse) {
|
||||
if (mLeft != 0) {
|
||||
if (mLeftDrawable != null) {
|
||||
mLeftDrawable.setBounds(0, mTop, mLeft, getHeight() - mBottom);
|
||||
mLeftDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mRight != 0) {
|
||||
if (mRightDrawable != null) {
|
||||
mRightDrawable.setBounds(getWidth() - mRight, mTop, getWidth(), getHeight() - mBottom);
|
||||
mRightDrawable.draw(canvas);
|
||||
if (mRight != 0) {
|
||||
if (mRightDrawable != null) {
|
||||
mRightDrawable.setBounds(getWidth() - mRight, mTop, getWidth(), getHeight() - mBottom);
|
||||
mRightDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mTop != 0) {
|
||||
if (leftBottomDrawable != null) {
|
||||
leftBottomDrawable.setBounds(0, 0, mLeft, mTop);
|
||||
leftBottomDrawable.draw(canvas);
|
||||
}
|
||||
if (isReverse) {
|
||||
if (leftBottomDrawable != null) {
|
||||
leftBottomDrawable.setBounds(0, 0, mLeft, mTop);
|
||||
leftBottomDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
if (bottomDrawable != null) {
|
||||
bottomDrawable.setBounds(mLeft, 0, getWidth() - mRight, mTop);
|
||||
bottomDrawable.draw(canvas);
|
||||
}
|
||||
if (bottomDrawable != null) {
|
||||
bottomDrawable.setBounds(mLeft, 0, getWidth() - mRight, mTop);
|
||||
bottomDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
if (rightBottomDrawable != null) {
|
||||
rightBottomDrawable.setBounds(getWidth() - mRight, 0, getWidth(), mTop);
|
||||
rightBottomDrawable.draw(canvas);
|
||||
if (rightBottomDrawable != null) {
|
||||
rightBottomDrawable.setBounds(getWidth() - mRight, 0, getWidth(), mTop);
|
||||
rightBottomDrawable.draw(canvas);
|
||||
}
|
||||
} else {
|
||||
if (leftTopDrawable != null) {
|
||||
leftTopDrawable.setBounds(0, 0, mLeft, mTop);
|
||||
leftTopDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
if (topDrawable != null) {
|
||||
topDrawable.setBounds(mLeft, 0, getWidth() - mRight, mTop);
|
||||
topDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
if (rightTopDrawable != null) {
|
||||
rightTopDrawable.setBounds(getWidth() - mRight, 0, getWidth(), mTop);
|
||||
rightTopDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mBottom != 0) {
|
||||
if (leftTopDrawable != null) {
|
||||
leftTopDrawable.setBounds(0, getHeight() - mBottom, mLeft, getHeight());
|
||||
leftTopDrawable.draw(canvas);
|
||||
}
|
||||
if (isReverse) {
|
||||
if (leftTopDrawable != null) {
|
||||
leftTopDrawable.setBounds(0, getHeight() - mBottom, mLeft, getHeight());
|
||||
leftTopDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
if (topDrawable != null) {
|
||||
topDrawable.setBounds(mLeft, getHeight() - mBottom, getWidth() - mRight, getHeight());
|
||||
topDrawable.draw(canvas);
|
||||
}
|
||||
if (topDrawable != null) {
|
||||
topDrawable.setBounds(mLeft, getHeight() - mBottom, getWidth() - mRight, getHeight());
|
||||
topDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
if (rightTopDrawable != null) {
|
||||
rightTopDrawable.setBounds(getWidth() - mRight, getHeight() - mBottom, getWidth(), getHeight());
|
||||
rightTopDrawable.draw(canvas);
|
||||
if (rightTopDrawable != null) {
|
||||
rightTopDrawable.setBounds(getWidth() - mRight, getHeight() - mBottom, getWidth(), getHeight());
|
||||
rightTopDrawable.draw(canvas);
|
||||
}
|
||||
} else {
|
||||
if (leftBottomDrawable != null) {
|
||||
leftBottomDrawable.setBounds(0, getHeight() - mBottom, mLeft, getHeight());
|
||||
leftBottomDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
if (bottomDrawable != null) {
|
||||
bottomDrawable.setBounds(mLeft, getHeight() - mBottom, getWidth() - mRight, getHeight());
|
||||
bottomDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
if (rightBottomDrawable != null) {
|
||||
rightBottomDrawable.setBounds(getWidth() - mRight, getHeight() - mBottom, getWidth(), getHeight());
|
||||
rightBottomDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user