我有一个用于几个不同地方的布局。
这个布局本身有一个 TextView 、一些按钮和一个进度条。
<LinearLayout id="reuse">
<TextView/>
<ProgressBar/>
<Buttons/>
</LinearLayout>
// in other places
<include layout="reuse"/> // text color blue here
// in other places
<include layout="reuse" /> //text color gree here
现在,根据包含布局的位置,我想为 TextView 指定不同的文本颜色。
如何做到这一点?我尝试在包含中指定文本颜色似乎没有帮助?
最佳答案
我能想到的唯一方法是以编程方式进行,只需使用线性布局“重用”的引用,并使用 reuse.findViewById() 从中获取 textview 并自己操作属性。
关于android - 为包含的布局 android 指定文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40892668/