android


Can Android drawable's clip-path layer be rotated?


I've just starting using clip-paths in vector drawables. I want to rotate the clip-path, but it's not possible to rotate any path without it being in a group, so that it could have pivotX and pivotY properties. However, when put in a group, it doesn't clip paths outside of a group anymore (and so becomes useless). Is there a workaround for this? This is my drawable (in this state, the clipping doesn't work because of what I mentioned):
<!-- drawable/bluetooth_audio.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="48dp"
android:width="48dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:name="maskGroup"
android:pivotX="12"
android:pivotY="12">
<clip-path
android:name="mask"
android:pathData="M12,0 V12 H24 V24 H0 V0"/>
</group>
<group
android:name="base"
android:pivotX="12"
android:pivotY="12">
<path
android:fillColor="#FFF"
android:pathData="M12.88,16.29L11,18.17V14.41M11,5.83L12.88,7.71L11,9.58M15.71,7.71L10,2
H9V9.58L4.41,5L3,6.41L8.59,12L3,17.58L4.41,19L9,14.41V22H10L15.71,16.29L11.41,12M19.53,6.71L18.26,8M14.24,12L16.56,14.33C16.84,13.6 17,12.82 17,12C17,11.18 16.84,10.4 16.57,9.68L14.24,12Z"/>
<path
android:fillColor="#FFF"
android:pathData="
M18.26,8
C18.89,9.18 19.25,10.55 19.25,12
C19.25,13.45 18.89,14.82 18.26,16
L19.46,17.22
C20.43,15.68 21,13.87 21,11.91
C21,10 20.46,8.23 19.53,6.71
"
/>
</group>
</vector>
Actually path and clip-path are use for different purpose.
Clip-path : use for get Canvas or say view-port for drawing.
Path : use for render paint on that view-port.
So, don't use clip-path for drawings or animation. If anything you draw outside of clip-path will nt be render or show. Ref : httpveloper.mozilla.org/en/docs/cz/SVG/Element/clipPath
It is possible to animate the changes of a clip-path, if the start and end states both have the same number of pathData steps; maybe instead of "rotating" the clip-path you define the end state of a "rotated" clip-path and then animate the clip-path? The objectAnimator to apply could look like this:
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="pathData"
android:valueFrom="M18 37 L38 37 L38 37 L18 37 Z"
android:valueTo="M0 0 L56 0 L56 56 L0 56 Z"
android:duration="600"
android:interpolator="#android:interpolator/fast_out_slow_in"
android:valueType="pathType" />
EDIT: Found this in the Android documentation
The AnimatedStateListDrawable class lets you create drawables that show animations between state changes of the associated view. Some of the system widgets in Android 5.0 use these animations by default. The following example shows how to define an AnimatedStateListDrawable as an XML resource:
The AnimatedStateListDrawable class lets you create drawables that show animations between state changes of the associated view. Some of the system widgets in Android 5.0 use these animations by default. The following example shows how to define an AnimatedStateListDrawable as an XML resource:
<!-- res/drawable/myanimstatedrawable.xml -->
<animated-selector
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- provide a different drawable for each state-->
<item android:id="#+id/pressed"
android:drawable="#drawable/drawableP"
android:state_pressed="true"/>
<item android:id="#+id/focused"
android:drawable="#drawable/drawableF"
android:state_focused="true"/>
<item android:id="#id/default"
android:drawable="#drawable/drawableD"/>
<!-- specify a transition -->
<transition android:fromId="#+id/default"
android:toId="#+id/pressed">
<animation-list>
<item android:duration="15"
android:drawable="#drawable/dt1"/>
<item android:duration="15"
android:drawable="#drawable/dt2"/>
...
</animation-list>
</transition>
...
</animated-selector>
https://developer.android.com/reference/android/graphics/drawable/AnimatedStateListDrawable.html
https://developer.android.com/training/material/animations.html#Transitions

Related Links

Lower battery consumption Android [duplicate]
“new String()” causes GC_CONCURRENT statements?
how to generate and display a moon image in android?
how to read and decode QR code image from SD card with zxing library? [duplicate]
Android POST without using NameValuePair
how to use google login information to login into my application
Wi-Fi tethering - how to get list of connected clients
openOptionsMenu function not working in ICS?
Why eclipse get closes whenever layout Xml file get clicked in android?
How do I decode a jpeg image encoded in Base64 in android and see it on an ImageView?
Can I turn off power save function of emulator?
Adding images to ListView items and to the details
How to develop Android Alarm application
Android install apk with Intent
Open with my app when I downloaded from Email as an attachment of my own extention file
Access TextView from outer class

Categories

HOME
codenvy
webdriver
solaris
seo
cq5
babeljs
echo
retrofit2
discrete-mathematics
okhttp
jquery-ui-sortable
ibeacon-android
startup
x-cart
spring-social
symmetricds
qsqlquery
bitnami
capistrano3
lilypond
google-maps-autocomplete
backpack-for-laravel
resourcebundle
expressionengine3
maze
fractions
inversion-of-control
angular-translate
exchangewebservices
iis-express
python-2.6
powershell-ise
jett
pop3
parse-tree
rfc3339
openal
wcftestclient
x-ray
git-flow
lsyncd
trigger.io
universal-analytics
google-photos
bootstrap-tags-input
lrs
google-query-language
kendo-upload
opl
tfs-workitem
android-launcher
opserver
git-ftp
addressing-mode
raygun
unix-socket
cuba
visual-studio-express
away3d
ui-select2
flex++
process-explorer
css-reset
video-codecs
idn
patricia-trie
boost-signals
multiplexing
wiimote
virtualpathprovider
jquery-tools
winmain
socketserver
globals
rowlex
interprocess
fail-fast-fail-early
technical-debt

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App