Java Android - LayerDrawable doesn't show

229 views Asked by At

I got a very strange case - I got 2 LayerDrawables to show progress of downloading and progress of audio playback.

here's free_downloads.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">   
    <clip    
    android:drawable="@drawable/play_fill_free_download"
    android:gravity="left" />
    </item>
 </layer-list>   

here's part of the code from MainActivity :

 LayerDrawable ld2= (LayerDrawable) getResources().getDrawable(R.drawable.free_downloads);
ClipDrawable cd2=(ClipDrawable) ld2.findDrawableByLayerId(R.id.clip);
cd2.setLevel(4300+(30*50));//it's just simulating of 50% progress - 4300 is a transparent space , 30 is a step and 50 is 50% of progress
((ImageView) findViewById(R.id.imageView1)).setImageDrawable(ld2);

so, inside my app it just show nothing, simply no image. But if I copy this code to a new project - everything works and show to me right picture.

What possibly could be wrong ? any idea ? I suspect that you can't tell by this information, but may there be something simple that I'm missing or anybode has same issue before?

0

There are 0 answers