简体   繁体   中英

How to extract supported XML Elements and Properties from a View?

Is there a way to extract the XML properties that a view supports? For example, an EditText has an XML property called Text , but on the Java side you use getText and setText .

I want to create a system that automatically discovers all the supported XML properties so I can verify the XML layout. At first just working with the default widgets is enough, but eventually I want to also enumerate custom widgets.

Both standard and custom XML attributes are defined in values/attrs.xml . In the case of the built in ones they are in android-sdk/platforms/android-X/data/res/values/attrs.xml .

It looks to me like you would have to find a way to parse these files to figure out which attributes can be associated with which views.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM