Android开textappearance运行 [英] android get textappearance runtime
本文介绍了Android开textappearance运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经重写了TextView的类,我想执行一些东西的时候textappearance小。
I have overriden the textview class and I want to perform some things when the textappearance is small.
我如何检查已设置的XML布局文件textappearance?
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;
}
如果构造函数调用这个函数不是我可以检查已设置为textappearance的ID。
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) {}
这篇关于Android开textappearance运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文