Reputation: 1954
I am trying to change the text color of a TextView
. This is the code I am using:
XML:
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/eks"
/>
Java:
@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")); }
Any ideas why the text color is not changing?
Upvotes: 2
Views: 7772
Reputation: 75
If you use the extend of theme Theme.AppCompat.Light.NoActionBar
,
color of the TextView
can't change any more.
Upvotes: 3
Reputation: 7115
I would use the Android Resources system to get everything jiving all nice and pretty.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
</resources>
<?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>
Upvotes: 1
Reputation: 2979
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/eks"
android:textColor="#ffffff" />
try this
Upvotes: 3