# android


05/18/2018, 2:44 PM
Hi, would like to validate an approach. Some time ago I asked here about kotlinx synthetic and long view ids. To give you an idea, I happened to work on a project with this frankenstein:

Possible solutions: 1) don't bother with synthetic 2) get rid of id prefixes, have ids with same names in different layouts and let the android to figure out the context As a proof of concept I decided to workaround with kotlin imports aliases, so I can rename my variables regardless of the actual xml id and here is a small demo of the plugin that helps to automate the process.

It's pretty much self-explanatory, the
Generate Synthetic
action is added, that imports ids from layout file with alias that can be edited to your taste. Also, it can be configured to convert underscore to camelCase. Now, the real question is, would it benefit anyone or I'm solving nonexistent problem?)

Davor Maric

05/21/2018, 12:50 AM
You can use already provided solution but as of kotlin intergration in android naming convention changed on XML files. Long story short: XML id's are now camelCase
You can google for new naming convention


05/21/2018, 8:17 AM
doesn't solve the long name problem. People use to prefix xml ids so they don't clash. In my kotlin code I know the context and don't need the prefix. Import alias allows you to have clean short names whilst having long xml ids.
another option would be having similar ids in different xmls. Like you have same
in 3 layouts and android will figure out which one is inflated. Not sure if it still works with latest gradle changes from I/O.