创建一个名为setTextcolor.mjave的模块
在 setTextcolor 模块中粘贴以下代码 import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.graphics.Color; private void getAllViews(ViewGroup viewGroup,String color) { for (int i=0;i < viewGroup.getChildCount(); i++) { View view = viewGroup.getChildAt(i); if (view instanceof ViewGroup) { getAllViews((ViewGroup) view,color); } else { String str = view + ""; //判断条件改成 view instanceof TextView 即匹配包含文字的控件 if (str.contains("android.widget.TextView")) { if (view.getVisibility() == View.VISIBLE) { //view.setBackgroundColor(Color.parseColor(color)); //设置文本背景 TextView textView =(TextView)view; textView.setTextColor(Color.parseColor(color)); //设置字体颜色 } } } } }
在需要设置的载入事件中使用以下代码调用 java(wind,activity,"android.app.Activity.getWindow") java(group,wind,"android.view.Window.getDecorView") call(null,"mjava","setTextcolor.getAllViews",group,"#ffffff") //#ffffff替换为你要的颜色