0

XML code

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- another items -->
    <item>
       <Bitmap android:src="@drawable/drawable_by_argument"/>
    </item>
</layer-list>

In code above i want to set Bitmap android:src attribute dynamicaly by some argument. Something like:

Java code

getResources().getDrawable(R.drawable.back, R.drawable.some_img);

Is it possible. If yes how can i do it.

Thanks for help.

InflexCZE
  • 722
  • 1
  • 14
  • 30

1 Answers1

1

no. it's not possible.

XML is not dynamic, it's static and heavy parsed during compiling time.

Budius
  • 39,391
  • 16
  • 102
  • 144