FlipImageView:能自動3d翻轉的ImageView
在實現數字的3d翻轉效果一文中,我們實現了數字的翻轉,本文我們利用類似的方法實現一個帶3D翻轉功能的ImageView。
FlipImageView可以使得一個ImageView點擊之后自動翻轉切換外觀,它的這個特性可以讓他代替傳統的ToggleButton控件。
FlipImageView項目地址:https://github.com/castorflex/FlipImageView
FlipImageView 內部已經包含了用于實現翻轉動畫的FlipAnimator,同時將點擊事件的監聽者設為自己,因此你只需如下運用FlipImageView 就能得到一個帶點擊翻轉動畫的ToggleButton控件:
<fr.castorflex.android.flipimageview.library.FlipImageView
xmlns:fiv="http://schemas.android.com/apk/res-auto"
android:id="@+id/imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/YOUR_DEFAULT_DRAWABLE"
fiv:flipDrawable="@drawable/YOUR_FLIPPED_DRAWABLE"
fiv:flipDuration="YOUR_DURATION_IN_MS"
fiv:flipInterpolator="@android:anim/YOUR_INTERPOLATOR"
fiv:flipRotations="none|x|y|z"
fiv:isAnimated="true|false"
fiv:isFlipped="true|false"/> 其中和ImageView不同的是需要制定兩個圖片資源文件,一個是正面的一個是反面的。
android:src="@drawable/YOUR_DEFAULT_DRAWABLE"正面。
fiv:flipDrawable="@drawable/YOUR_FLIPPED_DRAWABLE"反面。
最美壁紙應用中單張壁紙視圖與網格視圖之間的切換按鈕就是用FlipImageView 實現的。
本文由用戶 ElidaBerger 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!