How to use an XML layout as a display image

I would like to add XML Layoutas drawable imagefor GalleryView. Is it possible? here is the script i have one Layoutin my application. I would like to use images for my gallery, those images that look exactly the same as XML Layout(but the background and some other colors will be different). Therefore, instead of creating multiple images for the gallery, I want to use this xml layout as drawablesin the gallery window. Is it possible,? If so, how to do it? please help me with friends.

+5
source share
1 answer

See that I created XML like this

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/always_over" android:state_enabled="false"/>
<item android:drawable="@drawable/always_over" android:state_enabled="true" android:state_pressed="true"/>
<item android:drawable="@drawable/always_over" android:state_enabled="true" android:state_focused="true"/>
<item android:drawable="@drawable/always" android:state_enabled="true"/>

</selector>

And then set to Button

   <Button
        android:id="@+id/btnAlways"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/always_xml" />
+1
source

All Articles