阴影添加,对接v1d1的user.ghzhushou.com接口

This commit is contained in:
huangzhuanghua
2016-12-23 11:00:40 +08:00
parent 46668e32f6
commit 4b2e3d876b
36 changed files with 355 additions and 199 deletions

View File

@ -9,16 +9,16 @@ import android.widget.RelativeLayout;
import com.gh.gamecenter.R;
/**
* Created by LGT on 2016/9/9.
*/
public class CardRelativeLayout extends RelativeLayout {
private Drawable topDrawable, bottomDrawable;
private Drawable mLeftDrawable, mRightDrawable, topDrawable, bottomDrawable;
private Drawable leftTopDrawable, rightTopDrawable, leftBottomDrawable, rightBottomDrawable;
private int mLeft, mTop, mRight, mBottom;
private boolean isTran;
public CardRelativeLayout(Context context) {
this(context, null);
}
@ -34,13 +34,6 @@ public class CardRelativeLayout extends RelativeLayout {
private void init(Context context, AttributeSet attrs) {
setWillNotDraw(false);
topDrawable = getContext().getResources().getDrawable(R.drawable.frame_top);
bottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_bottom);
leftTopDrawable = getContext().getResources().getDrawable(R.drawable.frame_left_top_square);
rightTopDrawable = getContext().getResources().getDrawable(R.drawable.frame_right_top_square);
leftBottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_left_bottom_square);
rightBottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_right_bottom_square);
if (attrs != null) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CardLayout);
@ -48,13 +41,48 @@ public class CardRelativeLayout extends RelativeLayout {
mTop = ta.getDimensionPixelSize(R.styleable.CardLayout_top, 0);
mRight = ta.getDimensionPixelSize(R.styleable.CardLayout_right, 0);
mBottom = ta.getDimensionPixelSize(R.styleable.CardLayout_bottom, 0);
isTran = ta.getBoolean(R.styleable.CardLayout_tran, false);
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);
bottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_bottom);
leftTopDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_left_top_square);
rightTopDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_right_top_square);
leftBottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_tran_left_bottom_square);
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);
bottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_bottom);
leftTopDrawable = getContext().getResources().getDrawable(R.drawable.frame_left_top_square);
rightTopDrawable = getContext().getResources().getDrawable(R.drawable.frame_right_top_square);
leftBottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_left_bottom_square);
rightBottomDrawable = getContext().getResources().getDrawable(R.drawable.frame_right_bottom_square);
}
}
@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 (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);