当前位置: 首页 > news >正文

洛阳哪有做公司网站的/整合营销策划方案

洛阳哪有做公司网站的,整合营销策划方案,wordpress模块化主题,网站建设费 科研 设备费本文实例为大家分享了Android仿天猫加入购物车的具体代码,供大家参考,具体内容如下先上效果图实现思路:首先,我们需要三个Imagview第一个是原商品图片, 这个图片是布局文件中创建的 我们称作A第二个是做动画的图片 这个我们是在代码中创建的 …

本文实例为大家分享了Android仿天猫加入购物车的具体代码,供大家参考,具体内容如下

先上效果图

3629fcca031350a6d538dba5bea781fb.gif

实现思路:

首先,我们需要三个Imagview

第一个是原商品图片,  这个图片是布局文件中创建的       我们称作A

第二个是做动画的图片 这个我们是在代码中创建的     我们称作B

第三个是购物车图片   这个图片是布局文件中创建的     我们称作C

接着,我们需要将A图片设置给B

A图片一般是联网获取到的,给Imagview设置图片有两种方式

如果是通过setBackgroundDrawable      那么就通过getBackground()获取到Drawable对象,设置给B

如果是通过setImageDrawable      那么就通过getDrawable()获取到Drawable对象,设置给B

再接着   我们获取到A的位置  作为动画开始的位置     获取到C的位置    作为动画结束的位置

然后 创建动画图层,开始执行动画

这个动画集合中,包括:   水平位移匀速平移   竖直方向加速平移   缩放动画

最后  一定不要忘了  为我们的动画集合添加监听set.setAnimationListener

动画执行前让Imagview 可见     动画执行后让Imagview 不可见

下边是MainActivity中的代码

public class MainActivity extends Activity {

private ImageView top;

private ImageView bottom;

private ImageView animImageView;

private ViewGroup anim_mask_layout;// 动画层

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

top = (ImageView) findViewById(R.id.top);

bottom = (ImageView) findViewById(R.id.bottom);

}

public void startAnim(View view) {

// 记录开始的位置

int[] startLocation = new int[2];// 一个整型数组,用来存储按钮的在屏幕的X、Y坐标

top.getLocationInWindow(startLocation);// 这是获取购买按钮的在屏幕的X、Y坐标(这也是动画开始的坐标)

// 创建要做动画的ImageView

animImageView = new ImageView(this);

// 设置animImageView的背景

Drawable background = top.getBackground();

Drawable zoomDrawable = zoomDrawable(background, dip2Px(this, 200),

dip2Px(this, 200));

animImageView.setBackgroundDrawable(zoomDrawable);

// 开始执行动画

setAnim(animImageView, startLocation, top);

}

/**

* 设置动画

*

* @param v

* @param startLocation

* @param view

*/

private void setAnim(final View v, int[] startLocation, final View view) {

anim_mask_layout = null;

anim_mask_layout = createAnimLayout();

anim_mask_layout.addView(v);// 把动画小球添加到动画层

final View viewa = addViewToAnimLayout(anim_mask_layout, v,

startLocation);

int[] endLocation = new int[2];// 存储动画结束位置的X、Y坐标

bottom.getLocationInWindow(endLocation);// shopCart是那个购物车

// 计算位移

int endX = endLocation[0] - startLocation[0];// 动画位移的X坐标

int endY = endLocation[1] - startLocation[1];// 动画位移的y坐标

TranslateAnimation translateAnimationX = new TranslateAnimation(0,

endX, 0, 0);

translateAnimationX.setInterpolator(new LinearInterpolator());

translateAnimationX.setRepeatCount(0);// 动画重复执行的次数

translateAnimationX.setFillAfter(true);

TranslateAnimation translateAnimationY = new TranslateAnimation(0, 0,

0, endY);

translateAnimationY.setInterpolator(new AccelerateInterpolator());

translateAnimationY.setRepeatCount(0);// 动画重复执行的次数

translateAnimationX.setFillAfter(true);

ScaleAnimation scaleAnimation = new ScaleAnimation(0.6f, 0.1f,0.6f, 0.1f);

scaleAnimation.setInterpolator(new AccelerateInterpolator());

scaleAnimation.setRepeatCount(0);// 动画重复执行的次数

scaleAnimation.setFillAfter(true);

AnimationSet set = new AnimationSet(false);

set.setFillAfter(false);

set.addAnimation(scaleAnimation);

set.addAnimation(translateAnimationY);

set.addAnimation(translateAnimationX);

set.setDuration(600);// 动画的执行时间

viewa.startAnimation(set);

// 动画监听事件

set.setAnimationListener(new AnimationListener() {

// 动画的开始

@Override

public void onAnimationStart(Animation animation) {

v.setVisibility(View.VISIBLE);

}

@Override

public void onAnimationRepeat(Animation animation) {

}

// 动画的结束

@Override

public void onAnimationEnd(Animation animation) {

v.setVisibility(View.GONE);

}

});

}

/**

* @Description: 创建动画层

* @param

* @return void

* @throws

*/

private ViewGroup createAnimLayout() {

ViewGroup rootView = (ViewGroup) ((Activity) this).getWindow()

.getDecorView();

LinearLayout animLayout = new LinearLayout(this);

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(

LinearLayout.LayoutParams.MATCH_PARENT,

LinearLayout.LayoutParams.MATCH_PARENT);

animLayout.setLayoutParams(lp);

animLayout.setId(Integer.MAX_VALUE);

animLayout.setBackgroundResource(android.R.color.transparent);

rootView.addView(animLayout);

return animLayout;

}

private View addViewToAnimLayout(final ViewGroup parent, final View view,

int[] location) {

int x = location[0];

int y = location[1];

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(

LinearLayout.LayoutParams.WRAP_CONTENT,

LinearLayout.LayoutParams.WRAP_CONTENT);

lp.leftMargin = x;

lp.topMargin = y;

view.setLayoutParams(lp);

return view;

}

/**

* 将drawable对象进行指定大小的缩放

*

* @param drawable

* @param w

* @param h

* @return

*/

public Drawable zoomDrawable(Drawable drawable, int w, int h) {

int width = drawable.getIntrinsicWidth();

int height = drawable.getIntrinsicHeight();

Bitmap oldbmp = drawableToBitmap(drawable); // drawable 转换成 bitmap

Matrix matrix = new Matrix(); // 创建操作图片用的 Matrix 对象

float scaleWidth = ((float) w / width); // 计算缩放比例

float scaleHeight = ((float) h / height);

matrix.postScale(scaleWidth, scaleHeight); // 设置缩放比例

Bitmap newbmp = Bitmap.createBitmap(oldbmp, 0, 0, width, height,

matrix, true); // 建立新的 bitmap ,其内容是对原 bitmap 的缩放后的图

return new BitmapDrawable(newbmp); // 把 bitmap 转换成 drawable 并返回

}

/**

* 将drawable 转换成 bitmap

*

* @param drawable

* @return

*/

public Bitmap drawableToBitmap(Drawable drawable) {

int width = drawable.getIntrinsicWidth(); // 取 drawable 的长宽

int height = drawable.getIntrinsicHeight();

Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888

: Bitmap.Config.RGB_565; // 取 drawable 的颜色格式

Bitmap bitmap = Bitmap.createBitmap(width, height, config); // 建立对应

// bitmap

Canvas canvas = new Canvas(bitmap); // 建立对应 bitmap 的画布

drawable.setBounds(0, 0, width, height);

drawable.draw(canvas); // 把 drawable 内容画到画布中

return bitmap;

}

// dp转换为像素px

public static int dip2Px(Context context, float dp) {

final float scale = context.getResources().getDisplayMetrics().density;

return (int) (dp * scale + 0.5f);

}

}

下边是布局文件中代码

点击这里下载源码

http://www.lbrq.cn/news/786799.html

相关文章:

  • 甘肃省建设工程造价信息网站/域名注册费用
  • 平度做网站/线下推广方法有哪些
  • 网站开发所需技术/青岛网站制作
  • 邯郸网站制作费用/友情链接交换平台源码
  • 郑州专业做网站多少钱/优化大师客服
  • 百度互联网营销/上海关键词优化公司哪家好
  • 在深圳做的网站好做吗/淘宝seo排名优化软件
  • 圣辉友联做网站公司/2023年8月疫情又开始了吗
  • 做网站换服务器怎么整/做了5天游戏推广被抓了
  • 做图标得英文网站/如何推广我的网站
  • 莱芜四大金刚是谁啊/沈阳关键词seo排名
  • 桐庐县住房和城乡建设局网站/优化加速
  • 大连培训通网站建设/网页制作软件dw
  • apache做网站/关键词文案生成器
  • 网站站点建设中端口号的作用/百度推广客户端怎样注册
  • discuz wordpress 整合/谷歌seo搜索引擎下载
  • 濮阳网站制作/搜索引擎推广试题
  • 湛江网站制作/今日新闻摘抄
  • 石家庄微信网站建设/百度百度一下你就知道
  • 网站怎样做货到付款/怎样做网站平台
  • 衡水建设网站首页/谷歌优化怎么做
  • 手机网站跳转/网络营销网站
  • 网页制作手机软件下载/文山seo
  • 户外保险网站/seo 优化一般包括哪些内容
  • 腾讯云怎么备案网站吗/百度app下载安装普通下载
  • 做网站吉林/刷赞网站推广空间免费
  • 北京国际建设集团网站/企业网站优化工具
  • 在线编辑器/成都百度推广优化创意
  • wordpress 3.2/郑州seo实战培训
  • wordpress 网站建设/万网域名注册查询网
  • sqli-labs-master/Less-31~Less-40
  • 【深度学习新浪潮】近三年零样本图像分类研发进展调研
  • 基于高斯光束干涉的微球体相位成像系统设计与实现
  • Spring+K8s+AI实战:3全栈开发指南
  • ARPO:让LLM智能体更高效探索
  • 老电脑PE下无法读取硬盘的原因