0
Textview에서 확장 한 사용자 정의 클래스가 있으므로 레이아웃의 XML 값을 가져와야합니다. 시도했다XML의 속성 값에서 값 가져 오기
public FontTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setIncludeFontPadding(false);
int style = attrs.getAttributeIntValue(com.android.internal.R.styleable.TextAppearance_textStyle,-1);
init(style);
}
그러나 나는 com.android.internal.R.styleable
패키지가 존재하지 않는다고 말할 수 없다. 나는 밖에서 패키지에 접근 할 수 있다고 생각한다.
xml에서 스타일을 가져올 방법이 있습니까?
styleable.TextAppearance_textStyle
의 값은 -2001555입니다.이 값이 변경되거나 항상?를 사용하여 올바른 값을 가져올 수 있습니까?
int style = attrs.getAttributeIntValue(-2001555,-1)
아니, 그 ID가 내가 속성 세트의 값을 얻는 방법 때문에 컴파일시 – Blackbelt
에 구축 때문에 그것이 응용 프로그램을 중단 할 경우의 99 %에서? –
이 자습서가 도움이되는지 확인하십시오 : http://www.vogella.com/tutorials/AndroidCustomViews/article.html – luiscosta