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 are existing VPN applications creating new profiles in Android 2.0 - 2.3?
  • How to get the proper bounds of a view after transformation Matrix
  • SensorEventListener doesn't get unregistered with unregisterListener() method
  • How to change or add theme to Android Studio?
  • Android Facebook Video Upload Error Using Android API 4+
  • Large gap forms between RecyclerView items when scrolling down
  • Related posts:

    Transfer data through audio jack cable over two Android devices
    commitAllowingStateLoss() in fragment activities
    How to collect native stacktrace without a scary READ_LOGS permission up front?
    Android animation does not repeat
    Android How to add a custom xml file in res/values and how to register the customvalues.xml with the...
    Android, org.simpleframework.xml Persistence Exception, Element 'foo' is already u...
  • android Maps API v2 with custom markers
  • Good approach to manually retry requests in Retrofit Android
  • Making data persistent in android
  • Spinner functionality not working on Android 6.0.1
  • How to move buttons text when state is pressed
  • Unable to write jarlist cache file while creating android project
  • 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.