내 스타일을 내 앱 테마로 지정하려고합니다. 그러나 TextView에서 textColor를 변경하는 데 문제가 있습니다. 이것은 내 attrs.xml 파일입니다.테마로 Android TextView 변경 textColor
<?xml version="1.0" encoding="utf-8"?>
<declare-styleable name="flat">
<attr name="detail_name_view" format="reference" />
</declare-styleable>
이 내
styles.xml에서입니다
파일
<style name="flat_theme" parent="android:Theme.NoTitleBar">
<item name="detail_name_view">@style/flat_detail_name</item>
</style>
<style name="flat_detail_name" parent="@android:style/Widget.TextView">
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
<item name="android:textColor">@color/detail_group_black</item>
<item name="android:textSize">16sp</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
</style>
그리고 이것은 내 layout.xml 파일입니다
<TextView
android:id="@+id/detail_name"
style="?detail_name_view"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:gravity="left|center_vertical" />
또한 다음과 같이 올바르게 설정 한 매니페스트가 있습니다.
<application
android:name="com.example.blah"
android:icon="@drawable/blah"
android:label="@string/app_name"
android:theme="@style/flat_theme"
색상은 "@ color/detail_group_black"으로 변경되지 않습니다. 나는 간단한 것을 놓치고 있습니까? 또는 안드로이드가 이미 TextView를위한 textColor 속성을 만들고있어 스타일이 그것을 덮어 쓰지 않는 이유가 무엇입니까? 내 속성 테마 전략은 나머지 앱에서는 잘 작동하는 것으로 보이지만 그렇지 않은 것 같습니다. 어떤 아이디어? 미리 감사드립니다.
또한 도움이 될 수 있다면이 변경을 위해 사용자 지정 TextView 클래스를 만들지는 않을 것입니다. 상당히 큰 프로젝트이고 TextView를 확장하면 어떤 종류의 문제가 발생할 수 있는지 잘 모르겠습니다. 모두.
편집 또한 TextView를 style = "@ style/flat_detail_name_view"로 변경하면 잘 작동합니다. 내가 그렇게하고 싶지 않은 이유는 테마를 바꾸는 것만으로이 텍스트 뷰의 모습을 바꿀 수 있기 때문입니다. style = "? something_else"를 사용하면 다른 모든 뷰에서도 작동하므로 실제로 이것을 이해하지 못하고 단순한 내용이 누락 될 수 있습니까?
TextView 스타일에서 "? detail_name_view"란 무엇입니까? –
style = "? detail_name_view"는 detail_name_view 속성에 대한 참조입니다. –