android-layout - 动态设置 View 样式 : Android

标签 android-layout android android-styles

I want to change the look (Style) of various views dynamically in an Activity. But on going through various blogs, I came to know that android does not support dynamically setting styles for Views programmatic / dynamic., though I am not sure.

1) 除了使用 THEMES 或使用具有预设样式的布局 xml 文件 之外,还有其他实现方式吗?

2) 是否可以为各种 View 设置不同的样式(例如绿色文本 TextView1红色文本 < strong>TextView2) 通过对整个 Activity 使用 setTheme()?

谢谢

最佳答案

您可以像这样更改 java 文件中的文本颜色。

textview1.setTextColor(Color.GREEN);

textview2.setTextColor(Color.RED);

关于android-layout - 动态设置 View 样式 : Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14499327/

相关文章:

android - 唤醒锁 sleep 困惑

android - 向谷歌地图添加大数据层 - Android

android在styles.xml中设置自定义属性并进入程序

没有填充的 Android 按钮

android - 可绘制为 CardView 的背景

android - 将新项目计数添加到按钮上的图标 - Android

android - google play services 7.3.0 导致崩溃

android - 样式不适用于 Spinner?

android - ArrayApdapter 中的 getView() 返回错误的位置

android - Imageview 不应用 fitSystemWindows