私は非常に奇妙なケースを手に入れました - ダウンロードの進行状況とオーディオ再生の進行状況を表示するために 2 つの LayerDrawables を取得しました。
ここに 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>
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);
そのため、私のアプリ内では何も表示されず、単に画像が表示されません。しかし、このコードを新しいプロジェクトにコピーすると、すべてが機能し、正しい図が表示されます。
何が間違っている可能性がありますか? 何か案が ?この情報では判断できないと思いますが、私が見逃している単純なものがあるのでしょうか、それとも以前に同じ問題を抱えている人がいるでしょうか?