處理小表徵圖位子,處理表徵圖位子

來源:互聯網
上載者:User

處理小表徵圖位子,處理表徵圖位子

/**     2      * 初始化動畫,這個就是頁卡滑動時,下面的橫線也滑動的效果,在這裡需要計算一些資料     3 */  private int offset = 0;// 動畫圖片位移量 private int bmpW;// 動畫圖片寬度 private ImageView imageView;private int currIndex = 0;// 當前頁卡編號     private void InitImageView() {         imageView= (ImageView)findViewById(R.id.main_cursor);               bmpW = BitmapFactory.decodeResource(getResources(), android.R.drawable.button_onoff_indicator_on).getWidth();// 擷取圖片寬度                DisplayMetrics dm = new DisplayMetrics();         getWindowManager().getDefaultDisplay().getMetrics(dm);         int screenW = dm.widthPixels;// 擷取解析度寬度         offset = (screenW / 3 - bmpW) / 2;// 計算位移量         Matrix matrix = new Matrix();         matrix.postTranslate(offset, 0);         imageView.setImageMatrix(matrix);// 設定動畫初始位置     }  class ViewPagerListener implements OnPageChangeListener{int one = offset * 2 + bmpW;// 頁卡1 -> 頁卡2 位移量          int two = one * 2;// 頁卡1 -> 頁卡3 位移量  @Overridepublic void onPageScrollStateChanged(int arg0) {}@Overridepublic void onPageScrolled(int arg0, float arg1, int arg2) {}@Overridepublic void onPageSelected(int position) {//actionBar.setSelectedNavigationItem(position);Animation animation = new TranslateAnimation(one*currIndex, one*position, 0, 0);//顯然這個比較簡潔,只有一行代碼。              currIndex = position;              animation.setFillAfter(true);// True:圖片停在動畫結束位置              animation.setDuration(300);              imageView.startAnimation(animation);           }}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.