为什么我的某些样式不适用于较低的 API?

Why are some of my styles not working with lower APIs?

我有一个小问题!

在我的 styles.xml 文件中,我有

<style name="TextViewStyle" parent="android:Widget.TextView">
    <item name="android:padding">20px</item>
    <item name="android:background">#9cd0e8</item>
    <item name="android:textColor">#254b7c</item>
    <item name="android:textSize">18sp</item>
    <item name="android:textStyle">bold</item>
</style>

在我的activity_main.xml中,我有

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:theme="@+styles/TextViewStyle"
    android:text="Sample Text"/>

我想做的是,在我的 Android 应用程序中,在某个 activity 上,我计划放置许多具有相似属性的 TextView。我没有在每个 TextView 实例中每次都编写这些 'properties',而是将它们组合在 styles.xml 文件中的样式中,并将每个 TextView 的主题设置为该样式。

它工作正常,可以做我想做的事,但只有 APIs 超过 21!我的应用程序应该支持 API 15 级以上的设备。为什么我的方法不适用于较低的 APIs?

请尽快提供帮助。我需要尽快完成它。

编辑

'working',我的意思是我在我的样式中设置的属性(填充、颜色等)按应有的方式出现在 TextView 上。然而,在较低的 APIs 中,TextViews 看起来好像我没有对它们应用任何属性。出现纯文本而不是样式文本。

  1. 从您的样式中删除父项
  2. 从 textView 中移除 android:theme,(为什么会有 + 号?)
  3. 而不是主题,将其放入您的 textView

style="@style/TextViewStyle"

顺便说一句,使用 dp 而不是 px ;)