1

のテキストの色を変更しようとしていますTextView。これは私が使用しているコードです:

XML:

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/eks"

    />

ジャワ:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_schedule);
        Intent intent = getIntent();
        TextView txt = (TextView) findViewById(R.id.textView1);

        txt.setTextColor(Color.parseColor("#FFFFFF"));  }

テキストの色が変わらない理由はありますか?

4

4 に答える 4

3
<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/eks"
    android:textColor="#ffffff" />

これを試して

于 2013-10-03T17:19:37.190 に答える
2

テーマの拡張を使用すると、テーマTheme.AppCompat.Light.NoActionBarの色がTextView変更できなくなります。

于 2016-04-10T04:26:53.070 に答える
1

私なら Android リソース システムを使って、すべてをきれいに整えます。

/res/values/colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="white">#FFFFFF</color>
</resources>

/res/layout/my_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/eks"
        android:textColor="@color/white" />
</LinearLayout>
于 2013-10-03T17:25:02.483 に答える
0

これを試して:

txt.setTextColor(Color.WHITE);
于 2013-10-03T17:16:50.693 に答える