最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android控件Tween動畫(補間動畫)實現(xiàn)方法示例

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

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

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

/**
 * 控件Tween動畫
 * 
 * @description:
 * @author ldm
 * @date 2016-6-22 下午5:26:24
 */
public class TweenActivity extends Activity {
  private SeekBar seekBarX;// 拖動條控件
  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:控件設置監(jiān)聽事件
   * @author ldm
   * @date 2016-6-22 下午5:26:26
   */
  private void initEvents() {
    // 按鈕X方向平移動畫
    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方向平移動畫
    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方向縮放動畫
    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方向縮放動畫
    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方向旋轉動畫
    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方向旋轉
            button.setRotationX((float) progress);
          }
        });
    // 按鈕Y方向旋轉動畫
    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方向旋轉
            button.setRotationY((float) progress);
          }
        });
    // 按鈕Z方向旋轉動畫
    rotationSeekBarZ
        .setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          public void onStopTrackingTouch(SeekBar seekBar) {
          }
          public void onStartTrackingTouch(SeekBar seekBar) {
          }
          public void onProgressChanged(SeekBar seekBar,
              int progress, boolean fromUser) {
            // 設置旋轉
            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>

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

希望本文所述對大家Android程序設計有所幫助。

相關文章

  • Android自定義dialog 自下往上彈出的實例代碼

    Android自定義dialog 自下往上彈出的實例代碼

    本文通過實例代碼給大家介紹了Android自定義dialog 自下往上彈出效果,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友參考下吧
    2018-08-08
  • Android中各種Time API詳細

    Android中各種Time API詳細

    這篇文章要分享的是Android中各種Time API, SystemClock.uptimeMillis()、System.nanoTime(),下面我們就來看看他們到底有什么區(qū)別吧
    2021-10-10
  • Android中Dialog對話框的使用小結

    Android中Dialog對話框的使用小結

    這篇文章主要給大家總結了一些關于Android中Dialog對話框的使用方法,這其中包括普通對話框、確定取消對話框、多按鈕對話框、列表對話框、帶Adapter的對話框、單選對話框以及多選對話框等,需要的朋友可以參考學習,下面來一起看看詳細的介紹吧。
    2017-04-04
  • Android實現(xiàn)界面定時刷新功能

    Android實現(xiàn)界面定時刷新功能

    在移動應用中,界面定時刷新是非常常見的需求,本教程將以一個“實時時鐘”示例為主線,演示多種常用的定時刷新的實現(xiàn)方式,并對比它們的代碼簡潔度、性能消耗、生命周期管理與取消機制,幫助您在項目中快速選型并上手,需要的朋友可以參考下
    2025-04-04
  • Android適配器(Adapter)的概念與自定義

    Android適配器(Adapter)的概念與自定義

    這篇文章主要給大家介紹了關于Android適配器(Adapter)的相關資料,適配器是一個非常重要的知識點,Adapter是用來幫助填出數(shù)據(jù)的中間橋梁,本文介紹的非常詳細,需要的朋友可以參考下
    2021-07-07
  • Android將Glide動態(tài)加載不同大小的圖片切圓角與圓形的方法

    Android將Glide動態(tài)加載不同大小的圖片切圓角與圓形的方法

    這篇文章主要給大家介紹了關于Android如何將Glide動態(tài)加載不同大小的圖片切圓角與圓形的方法,文中通過示例代碼介紹的非常吸納關系,對各位Android開發(fā)者們具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧。
    2017-11-11
  • 分析Android 11.0Settings源碼之主界面加載

    分析Android 11.0Settings源碼之主界面加載

    這篇文章主要介紹了分析Android 11.0Settings源碼之主界面加載,對Android源碼感興趣的同學,可以著重看一下
    2021-04-04
  • Android Studio中debug功能詳解

    Android Studio中debug功能詳解

    這篇文章主要為大家詳細介紹了Android Studio中debug功能的相關資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Android自定義控件繪制基本圖形基礎入門

    Android自定義控件繪制基本圖形基礎入門

    這篇文章主要為大家詳細介紹了Android自定義控件繪制基本圖形基礎入門資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • Android ViewFlipper的詳解及實例

    Android ViewFlipper的詳解及實例

    這篇文章主要介紹了Android ViewFlipper的詳解及實例的相關資料,通過本文希望能幫助大家理解這部分內(nèi)容,需要的朋友可以參考下
    2017-08-08

最新評論

宜阳县| 石楼县| 绥阳县| 随州市| 邓州市| 九寨沟县| 明水县| 两当县| 临邑县| 扶风县| 漳平市| 射洪县| 郓城县| 紫金县| 财经| 西乌珠穆沁旗| 霍林郭勒市| 邛崃市| 铜梁县| 民勤县| 博湖县| 花莲县| 兴城市| 星座| 徐水县| 陈巴尔虎旗| 五寨县| 佛坪县| 周至县| 巴中市| 泸溪县| 中阳县| 玉溪市| 沈丘县| 如皋市| 永登县| 惠水县| 文成县| 五家渠市| 察隅县| 翁源县|