1

Is there a way to do android:textColor programmatically for linearLayout which contains bunch of textViews?

Burhanuddin Rashid
  • 5,260
  • 6
  • 34
  • 51
Nazerke
  • 2,098
  • 7
  • 37
  • 57

2 Answers2

3

Assuming you have given id to your LinearLayout, this should work :

LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linear_layout);
    TextView textView;
    for (int i=0; i<linearLayout.getChildCount();i++)
    {
        View view = linearLayout.getChildAt(i);
        if (view instanceof TextView){
            textView = (TextView) view;
            textView.setTextColor(getResources().getColor(R.color.colorAccent));
        }
    }
Avin
  • 81
  • 4
0
( (ViewGroup) findViewById(android.R.id.content));
 for (int i = 0; i < count; i++) {
      View view = viewGroup.getChildAt(i);
      if (view instanceof TextView){
         TextView text= (TextView) view;
         text.setTextColor(Color.WHITE);
        }
    }
Nir Duan
  • 6,164
  • 4
  • 24
  • 38