3
我在使用AppCompat的Android上面臨這種奇怪的行爲。無法在Android上使用appcompat更改TextView的顏色
我的主題是:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/white</item>
<item name="colorPrimaryDark">@color/gray_dark</item>
<item name="colorAccent">@color/green</item>
<item name="actionMenuTextColor">@color/gray_dark</item>
</style>
<style name="MyTheme.GreenButton" parent="Widget.AppCompat.Button">
<item name="android:background">@drawable/green_button</item>
<item name="android:textColor">@color/white</item>
<item name="android:textSize">18sp</item>
</style>
在我的佈局,我有這個按鈕:
<Button
android:id="@+id/login_button_login"
style="@style/MyTheme.GreenButton"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Log in"/>
編譯Android上的6件作品完美。但是,在Android 5上,按鈕的文本顏色是黑色的,不能使用xml textColor進行更改。它通過在代碼中直接使用setTextColor來工作。
我缺少什麼?爲什麼appcompat主題會根據sdk版本而有所不同?這個問題也影響到我的文本瀏覽器都是灰色的。