【问题标题】:Android theme: textViewStyle, editTextStyle and buttonStyle not working on custom themeAndroid 主题:textViewStyle、editTextStyle 和 buttonStyle 不适用于自定义主题
【发布时间】:2020-12-25 21:55:06
【问题描述】:

我在 theme.xml 上的自定义主题定义存在问题。 我已经定义了我的自定义主题并设置为遵循我的按钮、文本视图和编辑文本的自定义样式。

<style name="QTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:fontFamily">@font/bahnschrift</item>
    <item name="android:textColor">@color/foreground_color</item>
    <item name="android:textViewStyle">@style/QTheme.TextView</item>
    <item name="editTextStyle">@style/QTheme.EditText</item>
    <item name="android:editTextStyle">@style/QTheme.EditText</item>
    <item name="buttonStyle">@style/QTheme.Button</item>
    <item name="android:buttonStyle">@style/QTheme.Button</item>
</style>

<!-- white button -->
<style name="QTheme.Button" parent="Widget.AppCompat.Button">
    ... all my item definitions ...
</style>

<style name="QTheme.EditText" parent="Widget.AppCompat.EditText">
    ... all my item definitions ...
</style>

<style name="QTheme.TextView" parent="Widget.AppCompat.TextView">
    ... all my item definitions ...
</style>

顺便说一句,这不能正常工作:我将主题设置为我在 Manifest.xml 上的活动,但按钮、文本视图和编辑文本没有我定义的样式。

<activity
        android:name=".activities.MyActivity"
        android:theme="@style/QTheme" />

有人可以帮助我吗?我做错了什么?

【问题讨论】:

    标签: android styles themes manifest


    【解决方案1】:

    使用&lt;item name="android:editTextStyle"&gt;@style/QTheme.EditText&lt;/item&gt;

    在您的 QTheme 样式标签中

    【讨论】:

      猜你喜欢
      • 2021-01-29
      • 1970-01-01
      • 2015-04-20
      • 2020-06-09
      • 2019-06-28
      • 1970-01-01
      • 1970-01-01
      • 2018-12-03
      • 2015-03-27
      相关资源
      最近更新 更多