In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to realize origami animation in Android". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to realize origami animation in Android.
Realization of layout
The first element of the design is a layout that can be folded in half. Our approach is quite bold: the main layout (FoldableItemLayout) contains only one specific layout (in baselayout). In the animation, BaseLayout writes its contents to the cache, which is a Bitmap object created specifically according to the size of the original layout.
Class FoldableItemLayout extends FrameLayout {@ Override protected void onSizeChanged (int w, int h, int oldw, int oldh) {Bitmap cacheBitmap = Bitmap.createBitmap (w, h, Bitmap.Config.ARGB_8888); mBaseLayout.setCacheCanvas (new Canvas (cacheBitmap));}} class BaseLayout extends FrameLayout {private Canvas mCacheCanvas; private void setCacheCanvas (Canvas cacheCanvas) {mCacheCanvas = cacheCanvas } @ Override public void draw (Canvas canvas) {mCacheCanvas.drawColor (0, PorterDuff.Mode.CLEAR); super.draw (mCacheCanvas);}}
In addition, two additional views (PartView) are required-- for the upper and lower halves of the image. They will display the corresponding data in the cache, which represents the upper and lower half of the image (Bitmap). The two views fill the entire area of the main layout, but show only the desired portion. To achieve this effect, we calculate the bounds of the bitmap-in the onDraw () method, we have the canvas draw the desired part through the [drawBitmap (Bitmap bitmap, Rect src, RectF dst, Paint paint)] (http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.RectF, android.graphics.Paint) method.
Then through the setRotationX () method to set the corresponding angle, try to rotate these additional views, so as to achieve independent rotation of the upper half and the lower part of the image. To achieve this, we added a new parameter called FoldRotation for FoldableItemLayout.
The range of FoldRotation parameters is (- 180180]:
FoldRotation=0: neither part rotates. In this case, we can skip the bitmap cache and display the original layout in real time.
0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.