2012-04-27 3 views
5

에서 현재 테마의 기본 텍스트 색상을 얻을하는 방법. 이 개요는 현재 테마의 기본 텍스트 색과 같은 색이어야합니다.(참고)리스트 뷰 (<i> listview_style.xml</i>)의 모든 항목에서 뇌졸중의 윤곽을 그리는 나는 모양 (<i> rect_shape.xml</i>)가 XML

XML 형식의에 이 있습니까? 스트로크의 android : color 값을 현재 텍스트 색상으로 설정 하시겠습니까?

주위에 비슷한 속성 (예 : How to get my own defined attribute value in my style)을 사용하여 고유 속성을 설정하려고 시도했지만 이것이 내가 원하는 것이라고 생각하지 않습니다. 어쨌든 나는 그것을 시도했지만 안드로이드 : 색상 값을 내 정의 된 속성 (android:color="?custom_stroke_color" InflateException을 던집니다.)으로 설정할 수 없습니다.

사용자가 테마를 전환 할 수 있기 때문에 동적

, rect_shape.xml에서 (색상 자원 예컨대 @color/white 또는 참조) 하나의 소정의 색은 옵션이 아니다.

어떤 도움을 주셔서 감사합니다 ...

rect_shape.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" > 

<stroke android:width="3dp" 
<!-- should be the current default text color --> 
    android:color="#FFF" /> 

<solid/> 
... 
</shape> 

listview_style.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@drawable/rect_shape" > 
... 
</LinearLayout> 

themes.xml

<resources> 
<style name="DarkTheme" parent="@style/Theme.Sherlock"> 
<!-- default text color is white --> 
... 
</style> 
<style name="LightTheme" parent="@style/Theme.Sherlock.Light"> 
<!-- default text color is black--> 
... 
</style> 
</resources> 

답변

0

drawable XML 파일의 테마 속성에 액세스하는 것은 Android 5.0 이상에서만 가능합니다.

This issue

를 참조하십시오
관련 문제