Android : Rotate Vector Image to 90 degree

Pratik Butani :

I have following code for my vector:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"

    android:viewportWidth="314.015"
    android:viewportHeight="314.015">
    <path
        android:fillColor="#FCD83500"
        android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
</vector>

and Output is:

enter image description here

But I want this image in all direction as below:

enter image description here enter image description here enter image description here

What I have tried:

Added <vector> tag in between <rotate> but its giving me warning like Element vector is not allowed here

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="90">

    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"

        android:viewportWidth="314.015"
        android:viewportHeight="314.015">
        <path
            android:fillColor="#FCD83500"
            android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
    </vector>
</rotate>

I have also tried to put <bitmap> tag in between <rotate> as below:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fromDegrees="90"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="90">

    <bitmap app:srcCompat="@drawable/ic_round" />

</rotate>

but its giving me 'src' attribute should be defined and I can't use src with vector images.

Any solution to use this (one image) with all angle?

NOTE: I want to use this image in <TextView> drawable.

jeevashankar :

Try This Way , I have used the group tag outside of the image path data in vector drawable file.

First Type :

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"

android:viewportWidth="314.015"
android:viewportHeight="314.015">
<group
    android:translateX="314.015"
    android:rotation="90">
<path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />

</group>
</vector>

Second Type :

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="314.015"
android:viewportHeight="314.015">
<group
    android:translateX="314"
    android:scaleX="-1"
android:rotation="0">
<path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
</group>
</vector>

Third type:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="314.015"
android:viewportHeight="314.015">
<group
    android:translateY="314.015"
    android:rotation="270">
<path
    android:fillColor="#FCD83500"
    android:pathData="M157.007,0C70.291,0 0,70.289 0,157.007c0,86.712 70.29,157.007 157.007,157.007c86.709,0 157.007,-70.295 157.007,-157.007C314.014,70.289 243.716,0 157.007,0zM31.403,157.015c0,-69.373 56.228,-125.613 125.604,-125.613V282.62C87.631,282.62 31.403,226.38 31.403,157.015z" />
</group>
</vector>

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to rotate a Line or an image from its bottom to 180 degree

分類Dev

How do I get my canvas image to rotate 90 degrees each time, its only rotating 180 degrees

分類Dev

Why shinydashboard changes the corner of a numericInput from round to 90 degree?

分類Dev

Rotate video 90 degrees in AVPlayerViewController - possible?

分類Dev

Rotate actual svg path 90 degrees?

分類Dev

How to rotate a computer drawing in 90 degrees

分類Dev

JavaScript image rotate permanently

分類Dev

Rotate image counterclockwise with JQueryRotate

分類Dev

how to rotate vector data in matlab

分類Dev

Android using vector drawable for image in customview with android < 5

分類Dev

How to rotate a AVCaptureVideoPreviewLayer by 90 degrees to correct it in iOS11?

分類Dev

CSS 3.0 rotate(90deg) is not a valid value for 'transform' property

分類Dev

Add all sizes of image asset in Android Studio with a PDF or Vector file

分類Dev

Rotate a control in android

分類Dev

Rotate clip art in android

分類Dev

PHP Image(png) positioning and rotate

分類Dev

Rotate Rectangular Canvas Image to Fit

分類Dev

image resize and then rotate in canvas - javascript

分類Dev

How to scale, rotate and crop an Image

分類Dev

Load and display an image: why is it rotated 90°?

分類Dev

Rotate an image without cropping in OpenCV in C++

分類Dev

Java: Rotate image towards mouse position?

分類Dev

android : Xfermode masking disappearing on 180 degree rotation of Canvas

分類Dev

Rotate d3.parset visualization 90 degrees (make horizontal instead of vertical)

分類Dev

How to rotate an x->n y->n object clockwise by 90°?

分類Dev

How to rotate 4 children within a circle 90 degrees every 3 seconds using CSS custom properties and transform?

分類Dev

Why do we need to specific size during vector image generation in Android Studio?

分類Dev

How to rotate every Nth element in a vector in c++

分類Dev

scroll rotate image working only one image with javascript

Related 関連記事

  1. 1

    How to rotate a Line or an image from its bottom to 180 degree

  2. 2

    How do I get my canvas image to rotate 90 degrees each time, its only rotating 180 degrees

  3. 3

    Why shinydashboard changes the corner of a numericInput from round to 90 degree?

  4. 4

    Rotate video 90 degrees in AVPlayerViewController - possible?

  5. 5

    Rotate actual svg path 90 degrees?

  6. 6

    How to rotate a computer drawing in 90 degrees

  7. 7

    JavaScript image rotate permanently

  8. 8

    Rotate image counterclockwise with JQueryRotate

  9. 9

    how to rotate vector data in matlab

  10. 10

    Android using vector drawable for image in customview with android < 5

  11. 11

    How to rotate a AVCaptureVideoPreviewLayer by 90 degrees to correct it in iOS11?

  12. 12

    CSS 3.0 rotate(90deg) is not a valid value for 'transform' property

  13. 13

    Add all sizes of image asset in Android Studio with a PDF or Vector file

  14. 14

    Rotate a control in android

  15. 15

    Rotate clip art in android

  16. 16

    PHP Image(png) positioning and rotate

  17. 17

    Rotate Rectangular Canvas Image to Fit

  18. 18

    image resize and then rotate in canvas - javascript

  19. 19

    How to scale, rotate and crop an Image

  20. 20

    Load and display an image: why is it rotated 90°?

  21. 21

    Rotate an image without cropping in OpenCV in C++

  22. 22

    Java: Rotate image towards mouse position?

  23. 23

    android : Xfermode masking disappearing on 180 degree rotation of Canvas

  24. 24

    Rotate d3.parset visualization 90 degrees (make horizontal instead of vertical)

  25. 25

    How to rotate an x->n y->n object clockwise by 90°?

  26. 26

    How to rotate 4 children within a circle 90 degrees every 3 seconds using CSS custom properties and transform?

  27. 27

    Why do we need to specific size during vector image generation in Android Studio?

  28. 28

    How to rotate every Nth element in a vector in c++

  29. 29

    scroll rotate image working only one image with javascript

ホットタグ

アーカイブ