I have overriden the textview class and I want to perform some things when the textappearance is small.
How do I check the textappearance that has been set by the xml layout file?
I have overriden the textview class and I want to perform some things when the textappearance is small.
How do I check the textappearance that has been set by the xml layout file?
i have found a workaround:
private int getTextAppearance(AttributeSet attrs, int defStyle) {
int answer = defStyle;
for(int i=0; i<attrs.getAttributeCount(); i++) {
if(attrs.getAttributeNameResource(i) == android.R.attr.textAppearance) {
String attrStringValue = attrs.getAttributeValue(i);
if(attrStringValue != null) {
attrStringValue = attrStringValue.replace("?", "");
answer = Integer.parseInt(attrStringValue);
}
}
}
return answer;
}
if the constructor calls this function than i can check the id that has been set as textappearance.
if(getTextAppearance(attrs, -1) == android.R.attr.textAppearanceSmall) {}
© 2022 - 2024 — McMap. All rights reserved.