Need to get an attribute for runtime
I've been researching this for days. There is a piece of code I am working on that depends on knowing whether clipToPadding is set to true or false. While the documentation provides a solution for setting this attribute, I 开发者_JAVA技巧cannot find an effective way to read the attribute that does not depend on XML. Ordinarily, this would not be a problem but the class I created is meant to be subclasses by layout objects and may or may not be generated by XML. Is there a way to get the value of clipToPadding without having to rely on XML attributes?
Thanks in advance, Fuzzical Logic
From Android's source code, the information you look for is in a private field called mGroupFlags. There is no read accessor for this field, so I guess using the xml attribute is your only way of doing this... or you could rewrite your ViewGroup (and children class) adding the missing accessor to get the clipToPadding attribute.
精彩评论