android图片放大动画效果,android图片由小慢慢变大的动画效果简单讲解

一、概述

RatingBar是SeekBar和ProgressBar的扩展,用星星来评级。使用的默认大小RatingBar时,用户可以触摸/拖动或使用键来设置评分,它有俩种样式(大、小),其中大的只适合指示,不适合于用户交互。

二、实例

1.布局文件

< ?xml version="1.0" encoding="utf-8"?>

< LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:paddingLeft="10dip"

android:layout_width="match_parent"

android:layout_height="match_parent">

< RatingBar android:id="@+id/ratingbar1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:numStars="3"

android:rating="2.5" />

< RatingBar android:id="@+id/ratingbar2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:numStars="5"

android:rating="2.25" />

< LinearLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginTop="10dip">

< TextView android:id="@+id/rating"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

< RatingBar android:id="@+id/small_ratingbar"

style="?android:attr/ratingBarStyleSmall"

android:layout_marginLeft="5dip"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_vertical" />

< /LinearLayout>

< RatingBar android:id="@+id/indicator_ratingbar"

style="?android:attr/ratingBarStyleIndicator"

android:layout_marginLeft="5dip"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center_vertical" />

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是Android实现图片放大缩小动画的方法: 1.在XML布局文件中添加ImageView组件,并设置其初始大小和位置。 2.在Java代码中,使用ObjectAnimator类创建一个动画对象,并设置动画的目标对象、属性和动画效果。 3.在动画结束后,需要将ImageView的大小和位置还原为初始状态。 具体实现步骤如下: ```xml <!-- 在XML布局文件中添加ImageView组件 --> <ImageView android:id="@+id/imageView" android:layout_width="200dp" android:layout_height="200dp" android:src="@drawable/image" android:scaleType="centerCrop" android:layout_centerInParent="true"/> ``` ```java // 在Java代码中实现动画效果 ImageView imageView = findViewById(R.id.imageView); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 创建动画对象 ObjectAnimator animatorX = ObjectAnimator.ofFloat(imageView, "scaleX", 1f, 1.5f); ObjectAnimator animatorY = ObjectAnimator.ofFloat(imageView, "scaleY", 1f, 1.5f); AnimatorSet set = new AnimatorSet(); set.play(animatorX).with(animatorY); set.setDuration(500); set.start(); // 动画结束后还原ImageView的大小和位置 set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { ObjectAnimator animatorX = ObjectAnimator.ofFloat(imageView, "scaleX", 1.5f, 1f); ObjectAnimator animatorY = ObjectAnimator.ofFloat(imageView, "scaleY", 1.5f, 1f); AnimatorSet set = new AnimatorSet(); set.play(animatorX).with(animatorY); set.setDuration(500); set.start(); } }); } }); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值