Android equivalent of Nibs?

324 Views Asked by At

I am an iOS developer who is new to Android dev. I'm wondering if there is an equivalent to nibs in Android dev.

For example:

  • I subclass Button to programmatically define behaviors like having the button spin on touchdown (similar to creating a .swift file and subclassing UIButton)
  • I can design the look of the button in XML once (similar to editing the xib file)
  • I can drag my new custom button from Android Studio's Layout Editor onto other views

what I have so far

I already know that subclassing views will make them appear in the palette, I just don't know how to design the look of a subclassed view using XML.

When I try to drag additional things into my button, it doesn't work (probably because I'm subclassing Button and not ViewGroup).

1

There are 1 best solutions below

0
Vahag Chakhoyan On

In android studio You can create some reusable.xml file in resource's layout directory, then create a new reusable.java java class and in constructor of this class use layout inflater of android studio to inflate reusable.xml view. Then you can do with inflated view what you want.