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

Android Recyclerview set field name inside new thread
How work TableLayout with imageButton?
Cannot connect to openfire server in android
Android Webview request desktop site not working
Youtube Get uploaded video list. FileNotFound Error
Android retrieving data with two line listview
Gradle build failed - unable to unzip
how to use spotify format to displayimage in android app
android studio migrated code binary xml issue coming
ConstraintLayout within scrollview
How to retain variable values in a fragment so when the fragment is launched again the value persists?
ListView inside ScrollView makes adapter call multiple times
GoogleMap is moved when another view is hidden, Xamarin
Pop up a new floatingActionButton when it disappear with the coordinator layout
Android design support library - version number and gradle error
Build failed after upgrade react native to 0.44 v

Categories

HOME
cobalt
c++11
mstest
graphics
appcelerator
yandex
cublas
aws-cli
rom
pyqt4
echo
google-cloud-datalab
boto3
elasticsearch-5
teechart
extjs4.2
heap
xcodebuild
dynatrace
chargify
fileserver
articulate-storyline
highstock
resourcebundle
draft-js-plugins
windows-server-2003
moses
postback
mockjax
left-join
catch-unit-test
autolisp
instantiation
reactjs.net
baidu-map
lubridate
raft
reason
imagenet
openalpr
reactivekit
sim-card
cin
chef-solo
vmware-fusion
wmp
apollostack
signal-strength
puredata
insight
payara-micro
reindex
pair-programming
java-6
vibrate
taocp
simplepie
grails-plugin
reporting-services-2012
flex4.6
uicolor
watch-os-2
deep
riot
project-organization
nupic
asyncdisplaykit
inf
character-replacement
concurrentmodification
ess
include-guards
text-search
pax-exam
slash
lasso
jdk1.7
liquid-layout
apache-commons-daemon
google-refine
broadband
deform
spy++
device-tree
unix-socket
mintty
functional-java
alternate
menubar
clickbank
android-audiorecord
accesscontrolexception
mt4j
ie8-compatibility-mode
cffile
cmmi
zope.interface
boost-signals
kqueue
isa-swizzling
cross-database
fsevents
dataform
fdf
lemmatization
change-management

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