Hello, I have inherited MyClipDrawable class from ClipDrawable class to get some non standard clipping behavior and I want to use MyClipDrawable within a LayerDrawable. The LayerDrawable should be inflated from xml resource. Using MyClipDrawable class in xml drawable definition seems not to be possible. Thus, I had the idea to define a ClipDrawable inside the xml and replace it programmatic from my code by MyClipDrawable. However, I do not manage to get access to the GradientDrawable that is inside the ClipDrawable. I added an ID to the <shape> tag and try to get access to the GradientDrawable via getResources().getDrawable(R.id.progress_shape) from my code. However, the Drawable returned by getResources().getDrawable(R.id.progress_shape) is a LayerDrawable.
Can somebody please explain to me why (a) this is a LayerDrawable and not a GradientDrawable and (b) how I could get access to the GradientDrawable. Comments how to use MyClipDrawable from within XML Drawable resource are welcome too. <!-------------------------XML Drawable definition------------------------------------------> <layer-list xmlns:android="http://schemas.android.com/apk/res/ android"> <!-- further items omitted --> <item android:id="@android:id/progress"> <clip android:gravity="left"> <shape android:id="@+id/progress_shape"> <!-- further definitions omitted --> </shape> </clip> </item> </layer-list> /**************************Java Code***********************************************/ private void replaceProgressClip() { LayerDrawable layerDrawable = (LayerDrawable) getProgressDrawable(); Drawable progressShape = getResources().getDrawable(R.id.progress_shape); Drawable myClipDrawable = new MyClipDrawable(progressShape, Gravity.LEFT, ClipDrawable.HORIZONTAL); layerDrawable.setDrawableByLayerId(R.id.progress, myClipDrawable); } Thanks a lot. Droid-san -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en