Android: How to write multiple selectors in a single xml file

In my application,I have 4 ImageButtons and each ImageButton have different source image based on their states.So maintaining 4 separate xml files for each of the button.

Is there any way to write all the selectors in a single xml file ?

  • How to have a Fullscreen Background Image (with center-crop) that doesn't Resize
  • Problem with 9 patch image as background
  • css3 transform rotate3d with perspective not working on Android
  • How can I set exact, repeating alarms in Android 4.4?
  • Saving data on external storage
  • Populating JSON from this link to android Listview
  • Related posts:

    Android 4.0 Sub-Title (section) Label Styling
    Android: Invalid use of SingleClientConnManager: connection still allocated
    Saving ORB feature vectors using OpenCV4Android (java API)
    Sliding up image with Official Support Library 23.x.+ bottomSheet like google maps
    enable/disable keyboard sound and vibration programmatically
    AppBarLayout, NestedScrollView, FrameLayout, what is the deal?
  • Android soft keyboard hides inputs from CordovaWebView when in fullscreen
  • Android create a spinner with items that have a hidden value and display some text?
  • updating Google play services in Emulator
  • How to put media controller button on notification bar?
  • How using SQLiteOpenHelper with database on sd-card?
  • How to Change the color of child divider of ExpanableListView by layout xml file?
  • One Solution collect form web for “Android: How to write multiple selectors in a single xml file”

    Not it’s not possible:

    The documentation says:
    A StateListDrawable is a drawable object defined in XML that uses a several different images to represent the same graphic, depending on the state of the object.

    note here: same graphic

    src: Drawable Resources

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.