I got an error in my logs so instead of layer-drawable I see no image.
12-07 12:45:42.988: W/ResourceType(19347): No package identifier when getting value for resource number 0x0000000d
12-07 12:45:42.990: W/ImageView(19347): Unable to find resource: 13
12-07 12:45:42.990: W/ImageView(19347): android.content.res.Resources$NotFoundException: Resource ID #0xd
12-07 12:45:42.990: W/ImageView(19347): at android.content.res.Resources.getValue(Resources.java:1019)
12-07 12:45:42.990: W/ImageView(19347): at android.content.res.Resources.getDrawable(Resources.java:663)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ImageView.resolveUri(ImageView.java:542)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ImageView.onMeasure(ImageView.java:647)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.measure(View.java:12773)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.measure(View.java:12773)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.setupChild(ListView.java:1878)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.makeAndAddView(ListView.java:1788)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.fillDown(ListView.java:676)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.fillSpecific(ListView.java:1335)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.layoutChildren(ListView.java:1613)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.AbsListView.onLayout(AbsListView.java:1910)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:925)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1633)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1491)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.LinearLayout.onLayout(LinearLayout.java:1404)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1602)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2583)
12-07 12:45:42.990: W/ImageView(19347): at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 12:45:42.990: W/ImageView(19347): at android.os.Looper.loop(Looper.java:137)
12-07 12:45:42.990: W/ImageView(19347): at android.app.ActivityThread.main(ActivityThread.java:4503)
12-07 12:45:42.990: W/ImageView(19347): at java.lang.reflect.Method.invokeNative(Native Method)
12-07 12:45:42.990: W/ImageView(19347): at java.lang.reflect.Method.invoke(Method.java:511)
12-07 12:45:42.990: W/ImageView(19347): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
12-07 12:45:42.990: W/ImageView(19347): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
12-07 12:45:42.990: W/ImageView(19347): at dalvik.system.NativeStart.main(Native Method)
I got a layer-list drawable fr_dwlds.xml :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/play_spare"/>
<item android:id="@+id/clip_dwl">
<clip
android:clipOrientation="horizontal"
android:drawable="@drawable/play_fill_free_download"
android:gravity="left" />
</item>
</layer-list>
the images play_spare and play_fill_free_download are there in resources, I checked them and they are ok.
just in case , here is the usage of this LayerDrawable in my code :
LayerDrawable ld2= (LayerDrawable) ctx.getResources().getDrawable(R.drawable.fr_dwlds);
ClipDrawable cd2=(ClipDrawable) ld2.findDrawableByLayerId(R.id.clip_dwl);
Log.d("MyLog","download image !imagestatus="+p.imagestatus+" level="+(4300+(30*p.imagestatus)));
cd2.setLevel(4300+(30*p.imagestatus));
((ImageView) view.findViewById(R.id.ivImage)).setImageDrawable(ld2);
I tried to delete this fr_dwlds.xml file, make another one, changed id for clip - nothing helps, but if I simply copy this code and resources without changing antything to a new project - everyting works fine.
So.. what is the problem and how to solve it?