1.自定view
This commit is contained in:
@@ -1,269 +1,269 @@
|
|||||||
//package com.xscm.moduleutil.view;
|
package com.xscm.moduleutil.view;
|
||||||
//
|
|
||||||
//import android.content.Context;
|
import android.content.Context;
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
//import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
//import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
//import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
//import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
//import android.view.View;
|
import android.view.View;
|
||||||
//import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
//import android.view.animation.RotateAnimation;
|
import android.view.animation.RotateAnimation;
|
||||||
//import android.widget.Button;
|
import android.widget.Button;
|
||||||
//import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
//import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
//import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
//
|
|
||||||
//import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
//
|
|
||||||
//import com.xscm.moduleutil.R;
|
import com.xscm.moduleutil.R;
|
||||||
//
|
|
||||||
//
|
|
||||||
//public class QXMeetGiftView extends RelativeLayout {
|
public class QXMeetGiftView extends RelativeLayout {
|
||||||
//
|
|
||||||
// private TextView giftNameLabel;
|
private TextView giftNameLabel;
|
||||||
// private ImageView giftPriceBgView;
|
private ImageView giftPriceBgView;
|
||||||
// private Button giftCoin;
|
private Button giftCoin;
|
||||||
// private ImageView bgImageView;
|
private ImageView bgImageView;
|
||||||
// private ImageView giftBgImageView;
|
private ImageView giftBgImageView;
|
||||||
// private ImageView giftImageView;
|
private ImageView giftImageView;
|
||||||
//
|
|
||||||
// // 自定义属性变量
|
// 自定义属性变量
|
||||||
// private int normalBgRes;
|
private int normalBgRes;
|
||||||
// private int lockBgRes;
|
private int lockBgRes;
|
||||||
// private int giftLightBgRes;
|
private int giftLightBgRes;
|
||||||
// private int priceBgRes;
|
private int priceBgRes;
|
||||||
// private int coinIconRes;
|
private int coinIconRes;
|
||||||
// private int giftNameColor;
|
private int giftNameColor;
|
||||||
// private int coinTextColor;
|
private int coinTextColor;
|
||||||
// private float giftNameSize;
|
private float giftNameSize;
|
||||||
// private float coinTextSize;
|
private float coinTextSize;
|
||||||
// private int bgBottomMargin;
|
private int bgBottomMargin;
|
||||||
// private int giftImageMargin;
|
private int giftImageMargin;
|
||||||
// private int priceBgHeight;
|
private int priceBgHeight;
|
||||||
// private int priceBgBottomMargin;
|
private int priceBgBottomMargin;
|
||||||
// private int lockGiftSize;
|
private int lockGiftSize;
|
||||||
// private int rotateDuration;
|
private int rotateDuration;
|
||||||
//
|
|
||||||
// private boolean isLockGift;
|
private boolean isLockGift;
|
||||||
// private Object model;
|
private Object model;
|
||||||
//
|
|
||||||
// public QXMeetGiftView(Context context) {
|
public QXMeetGiftView(Context context) {
|
||||||
// this(context, null);
|
this(context, null);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public QXMeetGiftView(Context context, @Nullable AttributeSet attrs) {
|
public QXMeetGiftView(Context context, @Nullable AttributeSet attrs) {
|
||||||
// this(context, attrs, 0);
|
this(context, attrs, 0);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public QXMeetGiftView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
public QXMeetGiftView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
// super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
// // 解析自定义属性
|
// 解析自定义属性
|
||||||
// initAttrs(context, attrs);
|
initAttrs(context, attrs);
|
||||||
// // 初始化子视图
|
// 初始化子视图
|
||||||
// initSubviews(context);
|
initSubviews(context);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 解析自定义属性,设置默认值
|
* 解析自定义属性,设置默认值
|
||||||
// */
|
*/
|
||||||
// private void initAttrs(Context context, AttributeSet attrs) {
|
private void initAttrs(Context context, AttributeSet attrs) {
|
||||||
// TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.QXMeetGiftView);
|
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.QXMeetGiftView);
|
||||||
//
|
|
||||||
// // 背景资源(默认使用原代码中的资源)
|
// 背景资源(默认使用原代码中的资源)
|
||||||
// normalBgRes = ta.getResourceId(R.styleable.QXMeetGiftView_normalBg, R.drawable.ac_left_gift_bg);
|
normalBgRes = ta.getResourceId(R.styleable.QXMeetGiftView_normalBg, R.mipmap.xlh_g_2);
|
||||||
// lockBgRes = ta.getResourceId(R.styleable.QXMeetGiftView_lockBg, R.drawable.ac_lock_gift_bg);
|
lockBgRes = ta.getResourceId(R.styleable.QXMeetGiftView_lockBg, R.mipmap.ic_launcher);
|
||||||
// giftLightBgRes = ta.getResourceId(R.styleable.QXMeetGiftView_giftLightBg, R.drawable.ac_lock_gift_light_bg);
|
giftLightBgRes = ta.getResourceId(R.styleable.QXMeetGiftView_giftLightBg, R.mipmap.jinb);
|
||||||
// priceBgRes = ta.getResourceId(R.styleable.QXMeetGiftView_priceBg, R.drawable.ac_meet_gift_name_bg);
|
priceBgRes = ta.getResourceId(R.styleable.QXMeetGiftView_priceBg, R.mipmap.ic_launcher);
|
||||||
// coinIconRes = ta.getResourceId(R.styleable.QXMeetGiftView_coinIcon, R.drawable.sky_item_coin);
|
coinIconRes = ta.getResourceId(R.styleable.QXMeetGiftView_coinIcon, R.mipmap.ic_launcher);
|
||||||
//
|
|
||||||
// // 文字样式
|
// 文字样式
|
||||||
// giftNameColor = ta.getColor(R.styleable.QXMeetGiftView_giftNameColor, 0xFFFFFFFF);
|
giftNameColor = ta.getColor(R.styleable.QXMeetGiftView_giftNameColor, 0xFFFFFFFF);
|
||||||
// coinTextColor = ta.getColor(R.styleable.QXMeetGiftView_coinTextColor, 0xFFC7BF62);
|
coinTextColor = ta.getColor(R.styleable.QXMeetGiftView_coinTextColor, 0xFFC7BF62);
|
||||||
// giftNameSize = ta.getDimension(R.styleable.QXMeetGiftView_giftNameSize, sp2px(12));
|
giftNameSize = ta.getDimension(R.styleable.QXMeetGiftView_giftNameSize, sp2px(12));
|
||||||
// coinTextSize = ta.getDimension(R.styleable.QXMeetGiftView_coinTextSize, sp2px(10));
|
coinTextSize = ta.getDimension(R.styleable.QXMeetGiftView_coinTextSize, sp2px(10));
|
||||||
//
|
|
||||||
// // 尺寸配置
|
// 尺寸配置
|
||||||
// bgBottomMargin = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_bgBottomMargin, dp2px(19));
|
bgBottomMargin = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_bgBottomMargin, dp2px(19));
|
||||||
// giftImageMargin = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_giftImageMargin, dp2px(6));
|
giftImageMargin = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_giftImageMargin, dp2px(6));
|
||||||
// priceBgHeight = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_priceBgHeight, dp2px(15));
|
priceBgHeight = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_priceBgHeight, dp2px(15));
|
||||||
// priceBgBottomMargin = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_priceBgBottomMargin, dp2px(15));
|
priceBgBottomMargin = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_priceBgBottomMargin, dp2px(15));
|
||||||
// lockGiftSize = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_lockGiftSize, dp2px(62));
|
lockGiftSize = ta.getDimensionPixelOffset(R.styleable.QXMeetGiftView_lockGiftSize, dp2px(62));
|
||||||
//
|
|
||||||
// // 动画时长
|
// 动画时长
|
||||||
// rotateDuration = ta.getInt(R.styleable.QXMeetGiftView_rotateDuration, 3000);
|
rotateDuration = ta.getInt(R.styleable.QXMeetGiftView_rotateDuration, 3000);
|
||||||
//
|
|
||||||
// ta.recycle(); // 回收资源,避免内存泄漏
|
ta.recycle(); // 回收资源,避免内存泄漏
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// private void initSubviews(Context context) {
|
private void initSubviews(Context context) {
|
||||||
// // 1. 主背景
|
// 1. 主背景
|
||||||
// bgImageView = new ImageView(context);
|
bgImageView = new ImageView(context);
|
||||||
// bgImageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
bgImageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||||
// bgImageView.setImageResource(normalBgRes); // 使用自定义属性
|
bgImageView.setImageResource(normalBgRes); // 使用自定义属性
|
||||||
// LayoutParams bgParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
LayoutParams bgParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||||
// bgParams.addRule(ALIGN_PARENT_TOP);
|
bgParams.addRule(ALIGN_PARENT_TOP);
|
||||||
// bgParams.addRule(ALIGN_PARENT_LEFT);
|
bgParams.addRule(ALIGN_PARENT_LEFT);
|
||||||
// bgParams.addRule(ALIGN_PARENT_RIGHT);
|
bgParams.addRule(ALIGN_PARENT_RIGHT);
|
||||||
// bgParams.bottomMargin = bgBottomMargin; // 使用自定义属性
|
bgParams.bottomMargin = bgBottomMargin; // 使用自定义属性
|
||||||
// addView(bgImageView, bgParams);
|
addView(bgImageView, bgParams);
|
||||||
//
|
|
||||||
// // 2. 礼物光效背景
|
// 2. 礼物光效背景
|
||||||
// giftBgImageView = new ImageView(context);
|
giftBgImageView = new ImageView(context);
|
||||||
// giftBgImageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
giftBgImageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||||
// giftBgImageView.setImageResource(giftLightBgRes); // 使用自定义属性
|
giftBgImageView.setImageResource(giftLightBgRes); // 使用自定义属性
|
||||||
// giftBgImageView.setVisibility(View.GONE);
|
giftBgImageView.setVisibility(View.GONE);
|
||||||
// LayoutParams giftBgParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
LayoutParams giftBgParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||||
// giftBgParams.addRule(ALIGN_PARENT_TOP);
|
giftBgParams.addRule(ALIGN_PARENT_TOP);
|
||||||
// giftBgParams.addRule(ALIGN_PARENT_LEFT);
|
giftBgParams.addRule(ALIGN_PARENT_LEFT);
|
||||||
// giftBgParams.addRule(ALIGN_PARENT_RIGHT);
|
giftBgParams.addRule(ALIGN_PARENT_RIGHT);
|
||||||
// giftBgParams.bottomMargin = bgBottomMargin; // 使用自定义属性
|
giftBgParams.bottomMargin = bgBottomMargin; // 使用自定义属性
|
||||||
// addView(giftBgImageView, giftBgParams);
|
addView(giftBgImageView, giftBgParams);
|
||||||
//
|
|
||||||
// // 3. 礼物图片
|
// 3. 礼物图片
|
||||||
// giftImageView = new ImageView(context);
|
giftImageView = new ImageView(context);
|
||||||
// giftImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
giftImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||||
// LayoutParams giftImageParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
LayoutParams giftImageParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||||
// giftImageParams.addRule(CENTER_IN_PARENT);
|
giftImageParams.addRule(CENTER_IN_PARENT);
|
||||||
// giftImageParams.setMargins(giftImageMargin, giftImageMargin, giftImageMargin, 0); // 使用自定义属性
|
giftImageParams.setMargins(giftImageMargin, giftImageMargin, giftImageMargin, 0); // 使用自定义属性
|
||||||
// addView(giftImageView, giftImageParams);
|
addView(giftImageView, giftImageParams);
|
||||||
//
|
|
||||||
// // 4. 价格背景
|
// 4. 价格背景
|
||||||
// giftPriceBgView = new ImageView(context);
|
giftPriceBgView = new ImageView(context);
|
||||||
// giftPriceBgView.setImageResource(priceBgRes); // 使用自定义属性
|
giftPriceBgView.setImageResource(priceBgRes); // 使用自定义属性
|
||||||
// LayoutParams priceBgParams = new LayoutParams(LayoutParams.MATCH_PARENT, priceBgHeight); // 使用自定义属性
|
LayoutParams priceBgParams = new LayoutParams(LayoutParams.MATCH_PARENT, priceBgHeight); // 使用自定义属性
|
||||||
// priceBgParams.addRule(ALIGN_PARENT_BOTTOM);
|
priceBgParams.addRule(ALIGN_PARENT_BOTTOM);
|
||||||
// priceBgParams.bottomMargin = priceBgBottomMargin; // 使用自定义属性
|
priceBgParams.bottomMargin = priceBgBottomMargin; // 使用自定义属性
|
||||||
// addView(giftPriceBgView, priceBgParams);
|
addView(giftPriceBgView, priceBgParams);
|
||||||
//
|
|
||||||
// // 5. 金币按钮
|
// 5. 金币按钮
|
||||||
// giftCoin = new Button(context);
|
giftCoin = new Button(context);
|
||||||
// giftCoin.setTextColor(coinTextColor); // 使用自定义属性
|
giftCoin.setTextColor(coinTextColor); // 使用自定义属性
|
||||||
// giftCoin.setTextSize(TypedValue.COMPLEX_UNIT_PX, coinTextSize); // 使用自定义属性
|
giftCoin.setTextSize(TypedValue.COMPLEX_UNIT_PX, coinTextSize); // 使用自定义属性
|
||||||
// // 金币图标
|
// 金币图标
|
||||||
// Drawable coinDrawable = getResources().getDrawable(coinIconRes); // 使用自定义属性
|
Drawable coinDrawable = getResources().getDrawable(coinIconRes); // 使用自定义属性
|
||||||
// coinDrawable.setBounds(0, 0, dp2px(12), dp2px(12));
|
coinDrawable.setBounds(0, 0, dp2px(12), dp2px(12));
|
||||||
// giftCoin.setCompoundDrawables(coinDrawable, null, null, null);
|
giftCoin.setCompoundDrawables(coinDrawable, null, null, null);
|
||||||
// giftCoin.setBackgroundColor(0x00000000); // 透明背景
|
giftCoin.setBackgroundColor(0x00000000); // 透明背景
|
||||||
// LayoutParams coinParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
LayoutParams coinParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||||
// coinParams.addRule(CENTER_IN_PARENT, TRUE);
|
coinParams.addRule(CENTER_IN_PARENT, TRUE);
|
||||||
// addView(giftCoin, coinParams);
|
addView(giftCoin, coinParams);
|
||||||
//
|
|
||||||
// // 6. 礼物名称
|
// 6. 礼物名称
|
||||||
// giftNameLabel = new TextView(context);
|
giftNameLabel = new TextView(context);
|
||||||
// giftNameLabel.setTextColor(giftNameColor); // 使用自定义属性
|
giftNameLabel.setTextColor(giftNameColor); // 使用自定义属性
|
||||||
// giftNameLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, giftNameSize); // 使用自定义属性
|
giftNameLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, giftNameSize); // 使用自定义属性
|
||||||
// giftNameLabel.setGravity(Gravity.CENTER);
|
giftNameLabel.setGravity(Gravity.CENTER);
|
||||||
// LayoutParams nameParams = new LayoutParams(LayoutParams.MATCH_PARENT, priceBgHeight); // 使用自定义属性
|
LayoutParams nameParams = new LayoutParams(LayoutParams.MATCH_PARENT, priceBgHeight); // 使用自定义属性
|
||||||
// nameParams.addRule(ALIGN_PARENT_BOTTOM);
|
nameParams.addRule(ALIGN_PARENT_BOTTOM);
|
||||||
// addView(giftNameLabel, nameParams);
|
addView(giftNameLabel, nameParams);
|
||||||
//
|
|
||||||
// // 调整层级
|
// 调整层级
|
||||||
// bringChildToFront(giftPriceBgView);
|
bringChildToFront(giftPriceBgView);
|
||||||
// bringChildToFront(giftCoin);
|
bringChildToFront(giftCoin);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void setIsLockGift(boolean isLockGift) {
|
public void setIsLockGift(boolean isLockGift) {
|
||||||
// this.isLockGift = isLockGift;
|
this.isLockGift = isLockGift;
|
||||||
//
|
|
||||||
// // 设置背景图片(使用自定义属性)
|
// 设置背景图片(使用自定义属性)
|
||||||
// int bgResource = isLockGift ? lockBgRes : normalBgRes;
|
int bgResource = isLockGift ? lockBgRes : normalBgRes;
|
||||||
// bgImageView.setImageResource(bgResource);
|
bgImageView.setImageResource(bgResource);
|
||||||
//
|
|
||||||
// // 显示/隐藏光效背景
|
// 显示/隐藏光效背景
|
||||||
// giftBgImageView.setVisibility(isLockGift ? View.VISIBLE : View.GONE);
|
giftBgImageView.setVisibility(isLockGift ? View.VISIBLE : View.GONE);
|
||||||
//
|
|
||||||
// // 调整礼物图片尺寸(使用自定义属性)
|
// 调整礼物图片尺寸(使用自定义属性)
|
||||||
// LayoutParams params = (LayoutParams) giftImageView.getLayoutParams();
|
LayoutParams params = (LayoutParams) giftImageView.getLayoutParams();
|
||||||
// if (isLockGift) {
|
if (isLockGift) {
|
||||||
// params.width = lockGiftSize;
|
params.width = lockGiftSize;
|
||||||
// params.height = lockGiftSize;
|
params.height = lockGiftSize;
|
||||||
// params.setMargins(0, 0, 0, 0);
|
params.setMargins(0, 0, 0, 0);
|
||||||
// } else {
|
} else {
|
||||||
// params.width = LayoutParams.MATCH_PARENT;
|
params.width = LayoutParams.MATCH_PARENT;
|
||||||
// params.height = LayoutParams.WRAP_CONTENT;
|
params.height = LayoutParams.WRAP_CONTENT;
|
||||||
// params.setMargins(giftImageMargin, giftImageMargin, giftImageMargin, 0);
|
params.setMargins(giftImageMargin, giftImageMargin, giftImageMargin, 0);
|
||||||
// }
|
}
|
||||||
// giftImageView.setLayoutParams(params);
|
giftImageView.setLayoutParams(params);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void setModel(Object model) {
|
public void setModel(Object model) {
|
||||||
// this.model = model;
|
this.model = model;
|
||||||
// // 实际业务中解析模型数据
|
// 实际业务中解析模型数据
|
||||||
// /*
|
/*
|
||||||
// if (model instanceof QXDrawGiftModel) {
|
if (model instanceof QXDrawGiftModel) {
|
||||||
// QXDrawGiftModel giftModel = (QXDrawGiftModel) model;
|
QXDrawGiftModel giftModel = (QXDrawGiftModel) model;
|
||||||
// giftNameLabel.setText(giftModel.getGiftName());
|
giftNameLabel.setText(giftModel.getGiftName());
|
||||||
// giftCoin.setText(giftModel.getGiftPrice());
|
giftCoin.setText(giftModel.getGiftPrice());
|
||||||
// // Glide.with(getContext()).load(giftModel.getBaseImage()).into(giftImageView);
|
// Glide.with(getContext()).load(giftModel.getBaseImage()).into(giftImageView);
|
||||||
// }
|
}
|
||||||
// */
|
*/
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void startAnimation() {
|
public void startAnimation() {
|
||||||
// // 礼物图片顺时针旋转(使用自定义动画时长)
|
// 礼物图片顺时针旋转(使用自定义动画时长)
|
||||||
// RotateAnimation rotateAnimation = new RotateAnimation(
|
RotateAnimation rotateAnimation = new RotateAnimation(
|
||||||
// 0, 360,
|
0, 360,
|
||||||
// Animation.RELATIVE_TO_SELF, 0.5f,
|
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||||
// Animation.RELATIVE_TO_SELF, 0.5f
|
Animation.RELATIVE_TO_SELF, 0.5f
|
||||||
// );
|
);
|
||||||
// rotateAnimation.setDuration(rotateDuration);
|
rotateAnimation.setDuration(rotateDuration);
|
||||||
// rotateAnimation.setRepeatCount(Animation.INFINITE);
|
rotateAnimation.setRepeatCount(Animation.INFINITE);
|
||||||
// rotateAnimation.setRepeatMode(Animation.RESTART);
|
rotateAnimation.setRepeatMode(Animation.RESTART);
|
||||||
// rotateAnimation.setInterpolator(getContext(), android.R.anim.linear_interpolator);
|
rotateAnimation.setInterpolator(getContext(), android.R.anim.linear_interpolator);
|
||||||
// giftImageView.startAnimation(rotateAnimation);
|
giftImageView.startAnimation(rotateAnimation);
|
||||||
//
|
|
||||||
// // 光效背景逆时针旋转
|
// 光效背景逆时针旋转
|
||||||
// RotateAnimation rotateAnimation1 = new RotateAnimation(
|
RotateAnimation rotateAnimation1 = new RotateAnimation(
|
||||||
// 0, -360,
|
0, -360,
|
||||||
// Animation.RELATIVE_TO_SELF, 0.5f,
|
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||||
// Animation.RELATIVE_TO_SELF, 0.5f
|
Animation.RELATIVE_TO_SELF, 0.5f
|
||||||
// );
|
);
|
||||||
// rotateAnimation1.setDuration(rotateDuration);
|
rotateAnimation1.setDuration(rotateDuration);
|
||||||
// rotateAnimation1.setRepeatCount(Animation.INFINITE);
|
rotateAnimation1.setRepeatCount(Animation.INFINITE);
|
||||||
// rotateAnimation1.setRepeatMode(Animation.RESTART);
|
rotateAnimation1.setRepeatMode(Animation.RESTART);
|
||||||
// rotateAnimation1.setInterpolator(getContext(), android.R.anim.linear_interpolator);
|
rotateAnimation1.setInterpolator(getContext(), android.R.anim.linear_interpolator);
|
||||||
// giftBgImageView.startAnimation(rotateAnimation1);
|
giftBgImageView.startAnimation(rotateAnimation1);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void resetAnimation() {
|
public void resetAnimation() {
|
||||||
// giftImageView.clearAnimation();
|
giftImageView.clearAnimation();
|
||||||
// giftBgImageView.clearAnimation();
|
giftBgImageView.clearAnimation();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void stopAnimation() {
|
public void stopAnimation() {
|
||||||
// giftImageView.clearAnimation();
|
giftImageView.clearAnimation();
|
||||||
// giftBgImageView.clearAnimation();
|
giftBgImageView.clearAnimation();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // dp转px
|
// dp转px
|
||||||
// private int dp2px(int dp) {
|
private int dp2px(int dp) {
|
||||||
// return (int) TypedValue.applyDimension(
|
return (int) TypedValue.applyDimension(
|
||||||
// TypedValue.COMPLEX_UNIT_DIP,
|
TypedValue.COMPLEX_UNIT_DIP,
|
||||||
// dp,
|
dp,
|
||||||
// getResources().getDisplayMetrics()
|
getResources().getDisplayMetrics()
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // sp转px
|
// sp转px
|
||||||
// private int sp2px(int sp) {
|
private int sp2px(int sp) {
|
||||||
// return (int) TypedValue.applyDimension(
|
return (int) TypedValue.applyDimension(
|
||||||
// TypedValue.COMPLEX_UNIT_SP,
|
TypedValue.COMPLEX_UNIT_SP,
|
||||||
// sp,
|
sp,
|
||||||
// getResources().getDisplayMetrics()
|
getResources().getDisplayMetrics()
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Getter方法
|
// Getter方法
|
||||||
// public TextView getGiftNameLabel() { return giftNameLabel; }
|
public TextView getGiftNameLabel() { return giftNameLabel; }
|
||||||
// public ImageView getGiftPriceBgView() { return giftPriceBgView; }
|
public ImageView getGiftPriceBgView() { return giftPriceBgView; }
|
||||||
// public Button getGiftCoin() { return giftCoin; }
|
public Button getGiftCoin() { return giftCoin; }
|
||||||
// public ImageView getBgImageView() { return bgImageView; }
|
public ImageView getBgImageView() { return bgImageView; }
|
||||||
// public ImageView getGiftBgImageView() { return giftBgImageView; }
|
public ImageView getGiftBgImageView() { return giftBgImageView; }
|
||||||
// public ImageView getGiftImageView() { return giftImageView; }
|
public ImageView getGiftImageView() { return giftImageView; }
|
||||||
// public boolean isLockGift() { return isLockGift; }
|
public boolean isLockGift() { return isLockGift; }
|
||||||
// public Object getModel() { return model; }
|
public Object getModel() { return model; }
|
||||||
//}
|
}
|
||||||
|
|||||||
@@ -469,4 +469,29 @@
|
|||||||
<attr name="selectedBackground" format="reference" />
|
<attr name="selectedBackground" format="reference" />
|
||||||
<attr name="normalBackground" format="reference" />
|
<attr name="normalBackground" format="reference" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="QXMeetGiftView">
|
||||||
|
<!-- 背景图片配置 -->
|
||||||
|
<attr name="normalBg" format="reference" /> <!-- 正常状态背景 -->
|
||||||
|
<attr name="lockBg" format="reference" /> <!-- 锁定状态背景 -->
|
||||||
|
<attr name="giftLightBg" format="reference" /> <!-- 礼物光效背景 -->
|
||||||
|
<attr name="priceBg" format="reference" /> <!-- 价格背景 -->
|
||||||
|
<attr name="coinIcon" format="reference" /> <!-- 金币图标 -->
|
||||||
|
|
||||||
|
<!-- 文字样式配置 -->
|
||||||
|
<attr name="giftNameColor" format="color" /> <!-- 礼物名称颜色 -->
|
||||||
|
<attr name="coinTextColor" format="color" /> <!-- 金币文字颜色 -->
|
||||||
|
<attr name="giftNameSize" format="dimension" /> <!-- 礼物名称字号 -->
|
||||||
|
<attr name="coinTextSize" format="dimension" /> <!-- 金币文字字号 -->
|
||||||
|
|
||||||
|
<!-- 尺寸配置 -->
|
||||||
|
<attr name="bgBottomMargin" format="dimension" /> <!-- 背景底部边距 -->
|
||||||
|
<attr name="giftImageMargin" format="dimension" /> <!-- 礼物图片边距 -->
|
||||||
|
<attr name="priceBgHeight" format="dimension" /> <!-- 价格背景高度 -->
|
||||||
|
<attr name="priceBgBottomMargin" format="dimension" /> <!-- 价格背景底部边距 -->
|
||||||
|
<attr name="lockGiftSize" format="dimension" /> <!-- 锁定状态礼物图片尺寸 -->
|
||||||
|
|
||||||
|
<!-- 动画配置 -->
|
||||||
|
<attr name="rotateDuration" format="integer" /> <!-- 旋转动画时长(ms) -->
|
||||||
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user