전체 응용 프로그램의 기본 스타일과 텍스트보기의 하위 스타일을 가지고 있습니다. 그러나 자식 스타일에서는 "accentColor"항목이 효과적이지 않습니다. 텍스트 뷰는 여전히 부모 스타일에서 accentColor를 사용합니다. 여기 colorAccent를 자식 테마로 재정의 할 수 없습니다.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">#00ff00</item> <!-- Green color -->
</style>
<style name="MyCustomTheme" parent="AppTheme">
<item name="colorAccent">#ff0000</item> <!-- Red color -->
</style>
</resources>
내 레이아웃 파일입니다 :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="io.github.seemuch.highlightexperiment.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textIsSelectable="true"
android:textColorHighlight=""
style="@style/TextViewTheme"/>
</RelativeLayout>
그리고 여기에 응용 프로그램의 스크린 샷입니다 : screenshot
당신이 볼 수 있듯이 여기
내 style.xml입니다 텍스트보기의 강조 색상은 녹색이며 TextViewTheme이 아닌 AppTheme의 accentColor입니다.텍스트 하이라이트의 색상을 변경하고 싶습니다. 텍스트보기에 "textColorHighlight"속성을 추가하여 강조 부분 자체를 변경할 수는 있지만 "앵커"의 색상은 변경되지 않습니다. 내가 찾은 유일한 방법은 강조 색상을 변경하는 것이었지만 전체 앱의 강조 색상을 변경하고 싶지 않았습니다.
누구나 아이 스타일에서 액센트 컬러를 만드는 법을 아는 사람이 있습니까? 또는 앵커의 색상을 변경하는 더 좋은 방법이 있습니까?
''태그 안에있는'manifest.xml'의 특정 활동에 테마를 추가 할 수 있습니다.이 태그는'AppTheme'을 오버라이드 할 것입니다. –
"android : style"대신 "android : style" "스타일"? –