How to do different mirror effects on selected image in android . Actually i tried with flip image but it is not effected much on image .please suggest any library or reference example code is available because im a fresher to android development but i have to do this project.please help me
Asked
Active
Viewed 1,060 times
1 Answers
0
To give the mirror image effect for an ImageView, simply use the Scale attributes for the Image. An example for this is given.
<ImageView
android:id="@+id/ImageView"
....
android:scaleX="-1"
android:scaleY="-1"
/>
The scaleX
value would flip the image horizontally and the scaleY
value would flip the image vertically. This attribute works for all other elements too.
Edit
To show both original and mirrored image, place them side by side in an activity/fragment. Then set the mirrored image to Invisible. You could use a button which OnClick would show set the mirrored image to visible. An Example would be something like this:
<ImageView
android:id="@+id/ImageOriginal"
....
android:scaleX="1"
android:scaleY="1"
/>
<ImageView
android:id="@+id/ImageMirrored"
....
android:scaleX="-1"
android:scaleY="=1"
android:visibility="invisible"
/>
Button Listener
ImageView imgmirror=(ImageView)findViewById(R.id.ImageMirrored);
imgmirror.setVisibility(View.VISIBLE);

Abhi
- 3,431
- 1
- 17
- 35
-
its helps thank you but i want to ask something is it possible to read all the pixels of image and with those pixels is it possible to do mirror effect like one side the original image and other side is mirrored image by by replacing image pixels – Hemanth Kumar Aug 03 '17 at 09:21
-
So you want to place original image and mirrored image side-by-side? – Abhi Aug 03 '17 at 09:24
-
yeah https://i0.wp.com/bn-amras.com/wp-content/files/2016/01/3335.png see this image i want to do like this – Hemanth Kumar Aug 03 '17 at 09:56
-
and also i want one thing when i touch on image with finger both images would move is it possible – Hemanth Kumar Aug 03 '17 at 10:28
-
Yes you could use `MotionEvent` since `OnTouch` would work only for a single element. Refer to [this solution](https://stackoverflow.com/a/5223177/7461132) to implement it. – Abhi Aug 03 '17 at 11:11