set a style programatically이 가능하지 않으므로 테마를 만들고 있는데이 테마는 필요한 곳의 활동에 적용됩니다.
는 속성이
styleable 지금처럼 res/values/attrs.xml
속성을 추가 만들기 :
<declare-styleable name="MyTheme">
<attr name="titleColor" format="color" />
<attr name="subtitleColor" format="color" />
<attr name="backgroundDrawable" format="reference" />
</declare-styleable>
MyTheme
아무 관련이 필요하지 않는 것 같습니다. 나는 그 속성들에 대한 네임 스페이스 일 뿐이라고 생각한다.
res/values/styles.xml
에서 스타일
만들기 :
<style name="MyTheme.LightRows">
<item name="titleColor">@color/black</item>
<item name="subtitleColor">@color/grey</item>
<item name="backgroundDrawable">@drawable/cell_bg</item>
</style>
이 AndroidManifest.xml
에서 활동
스타일을 적용 :
<activity android:name=".view.activity.LightActivity"
android:theme="@style/MyTheme.LightRows" />
android:textColor="?attr/titleColor"
:
참조 스타일리스트 행 (또는 무엇이든)에 사용되는 레이아웃에서
속성