이 테마를 구현하는 방법에 대한, 내 사용자 정의 스타일이 오버라이드 (override) 시스템 스타일이상한 충돌 "android.view.InflateException는 : 바이너리 XML 파일 라인 # 9 : 오류 팽창 클래스 <unknown>"선언 - styleable
테마를 방지하기 위해 속성을 정의했다. XML
<declare-styleable name="MyThemeBase">
<attr name="myTextColorHighlight" format="reference|color"/>
</declare-styleable>
<style name="MyThemeBase" parent="@style/Theme.AppCompat.Light">
...
</style>
<style name="MY.Theme.AppCompat.Light.Orange" parent="SCThemeBase">
<item name="myTextColorHighlight">@color/textcolor_highlight_orange</item>
</style>
<style name="MY.Theme.AppCompat.Light.Blue" parent="SCThemeBase">
<item name="myTextColorHighlight">@color/textcolor_highlight_blue</item>
</style>
나는 또한 정의 된 사용자 정의 TextAppearance styles.xml
<style name="My.TextAppearance.Medium" parent="@android:style/TextAppearance.Medium">
<!-- this line caused crash -->
<item name="android:textColor">?attr/myTextColorHighlight</item>
<!-- this worked -->
<!--<item name="android:textColor">@color/textcolor_highlight_orange</item>-->
</style>
레이아웃 xmls에서 MY.TextAppearance.Medium 스타일보다 위에 언급 된 일부 TextViews는 모든 것이 그렇게 좋았습니다. ListView가 있었다 하나의 텍스트 뷰를하고 설계하는 동안하지만 사고를 가지고, 스택 트레이스는 가장 이상한
android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.xxx.yyy.MyListAdatper.getView(MyListAdatper.java:46)
은 같은 스타일의 다른 TextViews 내가이 우연히 왜 아무 생각도 없어
좋은이었다. 일부 디버깅을 통해 방금 attr 참조 대신 직접 색상을 사용하는 경우에만 작동한다는 것을 알았습니다 (위 styles.xml의 주석을 확인하십시오). My.TextAppearance.Medium의 정의입니다.
누구든지 도움을받을 수 있습니까? 감사.
'? attr/myTextColorHighlight'이 (가) '? attr/textColorHighlight'가 아니어야합니까? –
@Kenny, myTextColorHighlight를 선언했습니다. – fifth
아, 죄송합니다. 내 사과. –