欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android控件Tween動(dòng)畫(補(bǔ)間動(dòng)畫)實(shí)現(xiàn)方法示例

 更新時(shí)間:2017年08月14日 09:34:34   作者:遲做總比不做強(qiáng)  
這篇文章主要介紹了Android控件Tween動(dòng)畫(補(bǔ)間動(dòng)畫)實(shí)現(xiàn)方法,結(jié)合具體實(shí)例形式分析了Android補(bǔ)間動(dòng)畫的原理、功能實(shí)現(xiàn)與布局相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了Android控件Tween動(dòng)畫(補(bǔ)間動(dòng)畫)實(shí)現(xiàn)方法。分享給大家供大家參考,具體如下:

Android動(dòng)畫中的Tween動(dòng)畫:是把控件對(duì)象不斷的進(jìn)行圖像變化來產(chǎn)生旋轉(zhuǎn)、平移、放縮和漸變等動(dòng)畫效果。

/**
 * 控件Tween動(dòng)畫
 * 
 * @description:
 * @author ldm
 * @date 2016-6-22 下午5:26:24
 */
public class TweenActivity extends Activity {
  private SeekBar seekBarX;// 拖動(dòng)條控件
  private SeekBar seekBarY;
  private SeekBar scaleSeekBarX;
  private SeekBar scaleSeekBarY;
  private SeekBar rotationSeekBarX;
  private SeekBar rotationSeekBarY;
  private SeekBar rotationSeekBarZ;
  private Button button;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tween);
    initViews();
    initEvents();
  }
  /**
   * 
   * @description:初始化控件
   * @author ldm
   * @date 2016-6-22 下午5:26:26
   */
  private void initViews() {
    button = (Button) findViewById(R.id.button);
    seekBarX = (SeekBar) findViewById(R.id.translationX);
    seekBarX.setMax(400);
    seekBarY = (SeekBar) findViewById(R.id.translationY);
    seekBarY.setMax(800);
    scaleSeekBarX = (SeekBar) findViewById(R.id.scaleX);
    scaleSeekBarX.setMax(50);
    scaleSeekBarX.setProgress(10);
    scaleSeekBarY = (SeekBar) findViewById(R.id.scaleY);
    scaleSeekBarY.setMax(50);
    scaleSeekBarY.setProgress(10);
    rotationSeekBarX = (SeekBar) findViewById(R.id.rotationX);
    rotationSeekBarX.setMax(360);
    rotationSeekBarY = (SeekBar) findViewById(R.id.rotationY);
    rotationSeekBarY.setMax(360);
    rotationSeekBarZ = (SeekBar) findViewById(R.id.rotationZ);
    rotationSeekBarZ.setMax(360);
  }
  /**
   * 
   * @description:控件設(shè)置監(jiān)聽事件
   * @author ldm
   * @date 2016-6-22 下午5:26:26
   */
  private void initEvents() {
    // 按鈕X方向平移動(dòng)畫
    seekBarX.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
      public void onStopTrackingTouch(SeekBar seekBar) {
      }
      public void onStartTrackingTouch(SeekBar seekBar) {
      }
      public void onProgressChanged(SeekBar seekBar, int progress,
          boolean fromUser) {
        // X方向平移
        button.setTranslationX((float) progress);
      }
    });
    // 按鈕Y方向平移動(dòng)畫
    seekBarY.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
      public void onStopTrackingTouch(SeekBar seekBar) {
      }
      public void onStartTrackingTouch(SeekBar seekBar) {
      }
      public void onProgressChanged(SeekBar seekBar, int progress,
          boolean fromUser) {
        // Y方向平移
        button.setTranslationY((float) progress);
      }
    });
    // 按鈕X方向縮放動(dòng)畫
    scaleSeekBarX
        .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          public void onStopTrackingTouch(SeekBar seekBar) {
          }
          public void onStartTrackingTouch(SeekBar seekBar) {
          }
          public void onProgressChanged(SeekBar seekBar,
              int progress, boolean fromUser) {
            // X方向縮放
            button.setScaleX((float) progress / 10f);
          }
        });
    // 按鈕Y方向縮放動(dòng)畫
    scaleSeekBarY
        .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          public void onStopTrackingTouch(SeekBar seekBar) {
          }
          public void onStartTrackingTouch(SeekBar seekBar) {
          }
          public void onProgressChanged(SeekBar seekBar,
              int progress, boolean fromUser) {
            // Y方向縮放
            button.setScaleY((float) progress / 10f);
          }
        });
    // 按鈕X方向旋轉(zhuǎn)動(dòng)畫
    rotationSeekBarX
        .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          public void onStopTrackingTouch(SeekBar seekBar) {
          }
          public void onStartTrackingTouch(SeekBar seekBar) {
          }
          public void onProgressChanged(SeekBar seekBar,
              int progress, boolean fromUser) {
            // X方向旋轉(zhuǎn)
            button.setRotationX((float) progress);
          }
        });
    // 按鈕Y方向旋轉(zhuǎn)動(dòng)畫
    rotationSeekBarY
        .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          public void onStopTrackingTouch(SeekBar seekBar) {
          }
          public void onStartTrackingTouch(SeekBar seekBar) {
          }
          public void onProgressChanged(SeekBar seekBar,
              int progress, boolean fromUser) {
            // Y方向旋轉(zhuǎn)
            button.setRotationY((float) progress);
          }
        });
    // 按鈕Z方向旋轉(zhuǎn)動(dòng)畫
    rotationSeekBarZ
        .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          public void onStopTrackingTouch(SeekBar seekBar) {
          }
          public void onStartTrackingTouch(SeekBar seekBar) {
          }
          public void onProgressChanged(SeekBar seekBar,
              int progress, boolean fromUser) {
            // 設(shè)置旋轉(zhuǎn)
            button.setRotation((float) progress);
          }
        });
  }
}

布局文件R.layout.activity_tween

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  android:splitMotionEvents="true" >
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dip"
    android:orientation="horizontal"
    android:splitMotionEvents="true" >
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="5dip"
      android:paddingRight="5dip"
      android:text="TX"
      android:textStyle="bold" />
    <SeekBar
      android:id="@+id/translationX"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:orientation="horizontal" />
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="15dip"
      android:paddingRight="5dip"
      android:text="TY"
      android:textStyle="bold" />
    <SeekBar
      android:id="@+id/translationY"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:orientation="horizontal" />
  </LinearLayout>
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dip"
    android:orientation="horizontal"
    android:splitMotionEvents="true" >
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="5dip"
      android:paddingRight="5dip"
      android:text="SX"
      android:textStyle="bold" />
    <SeekBar
      android:id="@+id/scaleX"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:orientation="horizontal" />
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="15dip"
      android:paddingRight="5dip"
      android:text="SY"
      android:textStyle="bold" />
    <SeekBar
      android:id="@+id/scaleY"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:orientation="horizontal" />
  </LinearLayout>
  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dip"
    android:orientation="horizontal"
    android:splitMotionEvents="true" >
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="5dip"
      android:paddingRight="5dip"
      android:text="X"
      android:textStyle="bold" />
    <SeekBar
      android:id="@+id/rotationX"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:orientation="horizontal" />
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="15dip"
      android:paddingRight="5dip"
      android:text="Y"
      android:textStyle="bold" />
    <SeekBar
      android:id="@+id/rotationY"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:orientation="horizontal" />
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingLeft="15dip"
      android:paddingRight="5dip"
      android:text="Z"
      android:textStyle="bold" />
    <SeekBar
      android:id="@+id/rotationZ"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:orientation="horizontal" />
  </LinearLayout>
  <Button
    android:id="@+id/rotatingButton"
    android:layout_width="200dip"
    android:layout_height="150dip"
    android:layout_marginLeft="50dip"
    android:layout_marginTop="50dip"
    android:text="Rotating Button" />
</LinearLayout>

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)動(dòng)畫技巧匯總》、《Android開發(fā)入門與進(jìn)階教程》、《Android視圖View技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android文件操作技巧匯總》、《Android資源操作技巧匯總》及《Android控件用法總結(jié)

希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • android中在Activity中響應(yīng)ListView內(nèi)部按鈕的點(diǎn)擊事件的兩種方法

    android中在Activity中響應(yīng)ListView內(nèi)部按鈕的點(diǎn)擊事件的兩種方法

    本篇文章主要介紹了android中在Activity中響應(yīng)ListView內(nèi)部按鈕的點(diǎn)擊事件的兩種方法,有需要的可以了解一下。
    2016-11-11
  • android開發(fā)之Json文件的讀寫的示例代碼

    android開發(fā)之Json文件的讀寫的示例代碼

    這篇文章主要介紹了android開發(fā)之Json文件的讀寫的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-01-01
  • Kotlin高階函數(shù)reduce與fold使用實(shí)例

    Kotlin高階函數(shù)reduce與fold使用實(shí)例

    Kotlin的高階函數(shù)reduce和fold可以用來對(duì)集合進(jìn)行聚合操作。reduce函數(shù)將集合元素逐個(gè)累加,而fold函數(shù)則可以指定一個(gè)初始值進(jìn)行累加。這兩個(gè)函數(shù)在處理大數(shù)據(jù)集時(shí)非常有用
    2023-04-04
  • Android實(shí)現(xiàn)一鍵鎖屏功能

    Android實(shí)現(xiàn)一鍵鎖屏功能

    這篇文章主要介紹了Android實(shí)現(xiàn)一鍵鎖屏,在xml中創(chuàng)建device_admin.xml,在manifest中加入詳細(xì)文件,本文結(jié)合示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-10-10
  • Android三種常見的圖片壓縮方式

    Android三種常見的圖片壓縮方式

    在開發(fā)中,我們經(jīng)常有這樣一種需求,從相冊(cè)選擇圖片,上傳到服務(wù)器。隨著手機(jī)像素的不斷提升,照片也是小一點(diǎn)的3,4兆,大一點(diǎn)的多大10多兆。如果直接上傳原圖,會(huì)增大服務(wù)器壓力,所以,在上傳之前對(duì)圖片壓縮就顯得很必要了。
    2021-05-05
  • 使用Android Studio實(shí)現(xiàn)為系統(tǒng)級(jí)的app簽名

    使用Android Studio實(shí)現(xiàn)為系統(tǒng)級(jí)的app簽名

    這篇文章主要介紹了使用Android Studio實(shí)現(xiàn)為系統(tǒng)級(jí)的app簽名,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • Flutter 系統(tǒng)是如何實(shí)現(xiàn)ExpansionPanelList的示例代碼

    Flutter 系統(tǒng)是如何實(shí)現(xiàn)ExpansionPanelList的示例代碼

    Flutter組件有一個(gè)很大的特色,那就是很多復(fù)雜的組件都是通過一個(gè)一個(gè)小組件拼裝而成的,今天就來說說系統(tǒng)的ExpansionPanelList是如何實(shí)現(xiàn)的,需要的朋友可以參考下
    2020-05-05
  • android 中ProgressDialog實(shí)現(xiàn)全屏效果的示例

    android 中ProgressDialog實(shí)現(xiàn)全屏效果的示例

    本篇文章主要介紹了android 中ProgressDialog實(shí)現(xiàn)全屏效果的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-11-11
  • Android實(shí)現(xiàn)支付寶螞蟻森林水滴浮動(dòng)效果

    Android實(shí)現(xiàn)支付寶螞蟻森林水滴浮動(dòng)效果

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)支付寶螞蟻森林水滴浮動(dòng)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-06-06
  • android imageview圖片居中技巧應(yīng)用

    android imageview圖片居中技巧應(yīng)用

    做UI布局,尤其是遇到比較復(fù)雜的多重LinearLayout嵌套,常常會(huì)被一些比較小的問題困擾上半天,可是無論怎樣設(shè)置layout_gravity屬性,都無法達(dá)到效果
    2012-11-11

最新評(píng)論