I use a material icon (ic_play_arrow_black_24dp), imported it with the vector studio.
Now I want the arrow to point in the other direction as well, without creating a second vector. Is this possible in xml and how?
I use the drawable in two Floating Action Button, one for next the other for previous.
Edit here is the fab button's XML. I tried already rotation and scale, but it didn´t work
<android.support.design.widget.FloatingActionButton
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:layout_marginBottom="0dp"
android:layout_marginEnd="80dp"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
android:src="@drawable/next_prev_24dp"
app:layout_anchor="@id/next"
app:layout_anchorGravity="left" />
Use AnimatedVectorDrawable You normally define animated vector drawables in three XML files: A vector drawable with the <vector> element in res/drawable/ An animated vector drawable with the <animated-vector> element in res/drawable/ One or more object animators with the <objectAnimator> element in res/animator/
Enum values. Path.FillType. EVEN_ODD. Specifies that "inside" is computed by an odd number of edge crossings.
The major advantage of using a vector drawable is image scalability. It can be scaled without loss of display quality, which means the same file is resized for different screen densities without loss of image quality. This results in smaller APK files and less developer maintenance.
android:viewportWidth. Used to define the width of the viewport space. Viewport is basically the virtual canvas where the paths are drawn on. android:viewportHeight. Used to define the height of the viewport space.
For those who Use ImageView
or TextView
or EditText
Scale works perfectly. Use
android:scaleX="-1" //To flip horizontally or
android:scaleY="-1" //To flip vertically
OR Try
android:rotationX="180" // for horizontal
android:rotationY="180" // for vertical
OR Simply rotation="180"
for vertical
android:rotation="180" // for vertical
Edit: Additional
If you want to flip/mirror icons/drawable when changing language RTL/LTR ("Right To Left"/"Left To Right"), there is a nice way of doing so in android vector drawable just check the ckeckbox Enable auto mirroring for RTL layout.
=> Right Click on drawable folder => New => Vector Asset => Select drawable => check the Checkbox
.
I am using AndroidStudio 3.0.1
in Windows 10
.
well, there is no need to create another vector image, you can do it with one single vector image just make sure you do the following step while importing the vector image
So,
do usual step to create vector_drawable
,
in case some one don't know,
than here it is..
1.) Right Click on your package
of your app
2.) Than navigate to New => Vector Asset
3.) Than choose your desired icon, in @reebov case it will be ic_arrow_back_black_24dp
4.) You will find Checkbox
with the Option Enable auto mirroring for RTL layout
.
EDIT
You can also Set
android:autoMirrored="true"
in your XML vector file
see below image for more info
and your are done. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With