有没有办法在 android studio 的网格布局中更改所有文本视图的文本颜色属性?
is there a way to change all Text view's Text color attribute inside a Grid layout in android studio?
我有一个 grid layout
和里面的一些文本视图。我想知道是否有一种简单的方法可以同时更改所有 text view's
属性。即在某种程度上类似于网页设计中的 CSS
。
将每个 TextView 的样式 属性 设置为您定义的共享样式资源。例如:
自定义样式:
样式可以应用于特定视图。子视图不继承样式。
styles.xml:
<style name="MyStyle" parent="TextAppearance.AppCompat">
<item name="android:textColor">@color/indigo_text</item>
</style>
MyView.xml:
<TextView style="@style/MyStyle" ... />
自定义主题:
主题是可以应用于整个应用程序或特定视图及其所有后代的设置。
themes.xml:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColor">@color/indigo_text</item>
</style>
MyView.xml:
<FrameLayout android:theme="@style/MyTheme" ... />
或者为整个应用设置主题,更新清单文件中的应用定义:
<application android:theme="@style/MyTheme" ... />
关于主题的更多信息:https://developer.android.com/studio/write/theme-editor
我有一个 grid layout
和里面的一些文本视图。我想知道是否有一种简单的方法可以同时更改所有 text view's
属性。即在某种程度上类似于网页设计中的 CSS
。
将每个 TextView 的样式 属性 设置为您定义的共享样式资源。例如:
自定义样式:
样式可以应用于特定视图。子视图不继承样式。
styles.xml:
<style name="MyStyle" parent="TextAppearance.AppCompat">
<item name="android:textColor">@color/indigo_text</item>
</style>
MyView.xml:
<TextView style="@style/MyStyle" ... />
自定义主题:
主题是可以应用于整个应用程序或特定视图及其所有后代的设置。
themes.xml:
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColor">@color/indigo_text</item>
</style>
MyView.xml:
<FrameLayout android:theme="@style/MyTheme" ... />
或者为整个应用设置主题,更新清单文件中的应用定义:
<application android:theme="@style/MyTheme" ... />
关于主题的更多信息:https://developer.android.com/studio/write/theme-editor