TextView setTextColor is ignored when LinearLayout android:background is set
The code is at the very bottom. I can change the color of the text [android:id="@+id/vonage_login_status"] by running
vonage_login_status.setTextColor(this.getResources().getColor(R.color.light_grey));
However, I want a different colored background, so I added the line android:background="@color/background
But after I added the line, the setTextColor method is being ignored. Any ideas how do I fix it?
Thanks for reading....
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/vonage_login_status_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:clickable="true">
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:id="@+id/vonage_login_status"
android:layout_weight="1"
android:gravity="left"
android:singleLine="true"
android:ellipsize="end"
android:padding="0px">
</TextView>
</LinearLayout&开发者_StackOverflow中文版gt;
</LinearLayout>
</RelativeLayout>
I'm somewhat new to Android but I sometimes use these questions as a learning exercise, what you say you want to do seems to work for me and I learnt along the way. However, if that xml is all of the layout file it seems to have a lot of layouts stacked on top of one another and does not seem to nest properly, perhaps simplifying it would help.
精彩评论