1

カスタム テーマを使用してアプリケーション スタイルを管理しようとしています。

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
        <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
        <item name="actionBarTabStyle">@style/Widget.Sherlock.Light.ActionBar.TabView</item>
        <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
        <item name="android:textViewStyle">@style/MyTextViewStyle</item>
    </style>

    <style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
        <item name="background">@drawable/background</item>
        <item name="android:background">@drawable/background</item>
    </style>

    <style name="MyTextViewStyle" parent="@android:style/Widget.TextView">
        <item name="android:textColor">@color/text</item>
    </style>

</resources>

ご覧のとおり、TextView の既定の色を @color/text (#ff000000) に設定しています。これは、カスタム リスト アイテム レイアウトのものを除いて、アプリケーションのすべての TextView で正常に機能します。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/mov_concept"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="2dp"
        android:textSize="16dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/mov_category"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/mov_concept"
        android:layout_marginLeft="5dp"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/mov_amount"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/mov_category"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="6dp"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/mov_period"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/mov_amount"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/mov_until"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/mov_period"
        android:layout_alignBottom="@+id/mov_period"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="2dp"
        android:layout_marginRight="5dp"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
        android:id="@+id/mov_date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/mov_concept"
        android:layout_alignBottom="@+id/mov_category"
        android:layout_alignParentRight="true"
        android:layout_marginRight="5dp"
        android:layout_marginTop="2dp" />

</RelativeLayout>

どうしてこうなったのかわかりませんが、よろしくお願いします。

4

2 に答える 2

0

これは、スタイルの色をオーバーライドする aandroid:textAppearanceを適用するためです。textviews

于 2012-09-09T21:03:19.507 に答える