I am using the 3D flash card animation for Android (api> 14) and the problem with the tablet on the big screen (> 2048 dpi). While researching problems, I came to the following base unit:
I tried to just convert the view (simple ImageView) using the matrix and rotate the camera to some angle, and it works fine for the angle <60 and angle> 120 (it is converted and displayed), but the image disappears (just does not display) when the angle is between 60 and 120. Here is the code I'm using:
private void applyTransform(float degree) { float [] values = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}; float centerX = image1.getMeasuredWidth() / 2.0f; float centerY = image1.getMeasuredHeight() / 2.0f; Matrix m = new Matrix(); m.setValues(values); Camera camera = new Camera(); camera.save(); camera.rotateY(degree); camera.getMatrix(m); camera.restore(); m.preTranslate(-centerX, -centerY);
And here is my XML layout
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@drawable/naponer" android:clickable="true" android:scaleType="matrix"> </ImageView> </FrameLayout>
So, I have the following cases:
- works great for any angle, any center point works on small screens 800X480, 1024x720, etc.
- works fine for angles <60 and> 120 when working on large screens 2048x1536, 2560x1600 ...
- works fine for any angle on any device if the rotation is not centered (comments before and after the translation are commented out)
- it doesnโt work (the image disappears) when working on the deviceโs large screen, centering in the center and angle between 60 and 120 degrees.
Tell me what I'm doing wrong and advise a workaround ... thanks!
source share