安卓主题颜色

3

我正在尝试制作主题,并且问自己,是否可以为特定的textview设置不同的颜色。

例如:在“Theme.One”中,我希望在textview“Title”中使用绿色,在textview“text1”中使用粉色。

Themes.xml

  <style name="Theme.One" parent="@android:style/Theme.Light">
        <item name="android:background">@color/Azur</item>
        <item name="android:textColor">@color/Black</item>
        ...
      </style>
      <style name="Theme.Two" parent="@android:style/Theme.Light">
        <item name="android:background">@color/Blue</item>
        <item name="android:textColor">@color/White</item>
        ...
      </style>

Interface.xml

 <TextView
        android:text="@string/Title"
        android:id="@+id/Title"
        android:textSize="25sp" />
    <TextView
        android:text="@string/text1"
        android:id="@+id/text1"
        android:textSize="20sp" />

我希望已经将句子表达清楚,提前感谢您的回复,
Aziza
2个回答

0

你应该为粉色和绿色分别设置不同的样式。例如,对于绿色的TextView:

  <TextView
    android:text="@string/Title"
    android:id="@+id/Title"
    android:textSize="25sp"
   style="@style/Colorgreen"
 />

而对于你所拥有的风格

  <style name="Colorgreen">
       <item name="android:textColor">#00FF00</item>
        </style>   

0

在清单文件中:

  android:theme="@style/myTheme" 

在 res/values 文件夹中:

<style parent="@android:style/Theme.Dialog" name="myTheme">
    <item name="android:textColor">#00ff00</item>
    <item name="android:dateTextAppearance">?android:attr/textAppearanceSmall</item>
</style>

您可以将颜色更改为不同的颜色,并将该颜色应用于TextView。

 android:textColor="yourcolor"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接